C51 COMPILER V9.54 MSP_UART1 09/06/2024 14:31:11 PAGE 1 C51 COMPILER V9.54, COMPILATION OF MODULE MSP_UART1 OBJECT MODULE PLACED IN ..\out\msp_uart1.obj COMPILER INVOKED BY: E:\KeilC51\C51\BIN\C51.EXE ..\source\msp\uart\msp_uart1.c LARGE OMF2 OPTIMIZE(0,SIZE) BROWSE ORDER -NOINTPROMOTE INCDIR(..\source\bsp;..\source\msp;..\source\app;..\source\clib;..\source\cpu;..\source\ctask;..\source\tpc -;..\source\asp;..\source\debug;..\source\msp\uart;..\source\msp\simiic;..\source\bsp\oled;..\source\bsp\TTSSbsp) DEBUG P -RINT(..\out\msp_uart1.lst) TABS(2) OBJECT(..\out\msp_uart1.obj) line level source 1 #include "msp_uart1.h" *** WARNING C320 IN LINE 51 OF ..\source\bsp\TTSSbsp\bsp_config.h: "MainFre_22M" 2 ///#include "msp_time2.h" 3 #include "c_crc.h" 4 #include "c_delay.h" 5 //#include "tpc_debug.h" 6 #include "debug_drv.h" 7 #include "tpc_road.h" 8 //#define _USE_485 9 10 ///static volatile TS_Uart_Send_ ts_uart_send_shop; 11 12 ///>>>>>>>>>>>>>>>>和cpu相关 13 14 15 #if(MainFre_5M == D_sys_MainFre) #elif(MainFre_22M == D_sys_MainFre) 19 20 21 22 #if(BRT_921600 == D_UART1_BRT) void L0_uart1_init(void) /// void UartInit(void) //921600bps@22.1184MHz { SCON = 0x50; //8位数据,可变波特率 AUXR |= 0x40; //定时器时钟1T模式 AUXR &= 0xFE; //串口1选择定时器1为波特率发生器 TMOD &= 0x0F; //设置定时器模式 TL1 = 0xFA; //设置定时初始值 TH1 = 0xFF; //设置定时初始值 ET1 = 0; //禁止定时器中断 TR1 = 1; //定时器1开始计时 } #elif(BRT_460800 == D_UART1_BRT) #elif(BRT_115200 == D_UART1_BRT) void L0_uart1_init(void) /// void UartInit(void) //115200bps@22.1184MHz { SCON = 0x50; //8位数据,可变波特率 AUXR |= 0x40; //定时器时钟1T模式 AUXR &= 0xFE; //串口1选择定时器1为波特率发生器 TMOD &= 0x0F; //设置定时器模式 TL1 = 0xD0; //设置定时初始值 TH1 = 0xFF; //设置定时初始值 ET1 = 0; //禁止定时器中断 TR1 = 1; //定时器1开始计时 } #warning "MainFre_22M BRT_115200" #elif(BRT_19200 == D_UART1_BRT) #elif(BRT_9600== D_UART1_BRT) 51 void L0_uart1_init(void) //9600bps@22.1184MHz C51 COMPILER V9.54 MSP_UART1 09/06/2024 14:31:11 PAGE 2 52 { 53 1 SCON = 0x50; //8位数据,可变波特率 54 1 AUXR |= 0x40; //定时器时钟1T模式 55 1 AUXR &= 0xFE; //串口1选择定时器1为波特率发生器 56 1 TMOD &= 0x0F; //设置定时器模式 57 1 TL1 = 0xC0; //设置定时初始值 58 1 TH1 = 0xFD; //设置定时初始值 59 1 ET1 = 0; //禁止定时器中断 60 1 TR1 = 1; //定时器1开始计时 61 1 } 62 #warning "MainFre_22M BRT_115200" *** WARNING C320 IN LINE 62 OF ..\source\msp\uart\msp_uart1.c: "MainFre_22M BRT_115200" 63 #else///9600 #endif//) 65 66 67 68 69 #elif(MainFre_27M == D_sys_MainFre) #elif(MainFre_44M == D_sys_MainFre) #if(BRT_115200 == D_UART1_BRT) #elif(BRT_460800 == D_UART1_BRT) void L0_uart1_init(void) /// void UartInit(void) //460800bps@44.2368MHz { SCON = 0x50; //8位数据,可变波特率 AUXR &= 0xBF; //定时器时钟12T模式 AUXR &= 0xFE; //串口1选择定时器1为波特率发生器 TMOD &= 0x0F; //设置定时器模式 TL1 = 0xFE; //设置定时初始值 TH1 = 0xFF; //设置定时初始值 ET1 = 0; //禁止定时器%d中断 TR1 = 1; //定时器1开始计时 } #elif(BRT_921600 == D_UART1_BRT) void L0_uart1_init(void) /// void UartInit(void) //921600bps@44.2368MHz { SCON = 0x50; //8位数据,可变波特率 AUXR &= 0xBF; //定时器时钟12T模式 AUXR &= 0xFE; //串口1选择定时器1为波特率发生器 TMOD &= 0x0F; //设置定时器模式 TL1 = 0xFF; //设置定时初始值 TH1 = 0xFF; //设置定时初始值 ET1 = 0; //禁止定时器%d中断 TR1 = 1; //定时器1开始计时 } #info "0000" #elif(BRT_19200 == D_UART1_BRT) #elif(BRT_9600== D_UART1_BRT) #else///9600 #endif//D_sys_MainFre) #else ///MainFre_11M C51 COMPILER V9.54 MSP_UART1 09/06/2024 14:31:11 PAGE 3 #if(BRT_115200 == D_UART1_BRT) void L0_uart1_init(void) ///void UartInit(void) //115200bps@11.0592MHz { SCON = 0x50; //8位数据,可变波特率 AUXR |= 0x01; //串口1选择定时器2为波特率发生器 AUXR &= 0xFB; //定时器时钟12T模式 T2L = 0xFE; //设置定时初始值 T2H = 0xFF; //设置定时初始值 AUXR |= 0x10; //定时器2开始计时 } #elif(BRT_19200 == D_UART1_BRT) #elif(BRT_9600== D_UART1_BRT) #else///9600 #endif//D_sys_MainFre) #endif//D_sys_MainFre) 137 138 ///>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>和cpu相关 139 void L1_uart1_open(void) 140 {// 141 1 L0_uart1_buf_init();//串口初始化// 142 1 143 1 EA = 1; 144 1 L0_uart1_str("\r\nuart1 open"); 145 1 } 146 147 void L0_uart1_buf_init(void) 148 { 149 1 L0_uartN_sbuf(D_UART1); 150 1 D_s2b_road1_init(); 151 1 152 1 D_stdIO_P3(BITN1); 153 1 D_stdIO_P3(BITN0);////PIN19 TXD1 D+ 154 1 155 1 L0_uart1_init(); 156 1 L0_uart1_IntRIClear(); 157 1 L0_uart1_IntTIClear(); 158 1 D_UART1_RS_EN(1); 159 1 D_uart1_ES_INT(1); //打开串口中断 160 1 161 1 #if (D_UART1_485_TYPE != TYPE_485_NONE) D_UART1_485_RX(); //默认处于接收状态 #endif 164 1 } 165 /* 166 167 void L0_uart1_Array(U8 * buf, U16 len) 168 { 169 #if (D_UART1_485_TYPE != TYPE_485_NONE) 170 D_UART1_485_TX(); //切换到输出状态 171 #endif 172 L0_uartN_Array(D_UART1,buf,len); 173 } 174 */ C51 COMPILER V9.54 MSP_UART1 09/06/2024 14:31:11 PAGE 4 175 176 177 ////U8 overtime_t; //超时溢出的计数器 178 ////U8 overtime_flag; ///0:没有超时溢出 1:超时溢出 179 ////U8 over_flag; ////串口接收结束的状态 0:超时溢出 1:超出max接收 180 181 ///D_LED4_REV(); 182 183 void L2_uart1_overtime_callback(void) 184 {////必须清除当前的idle 185 1 if(0 == ts_Urec[D_UART1].idle) 186 1 { 187 2 if(ts_Urec[D_UART1].overtime_t >= 2) 188 2 { 189 3 ts_Urec[D_UART1].idle = 1;//总线空闲 190 3 ts_Urec[D_UART1].head = 0; 191 3 192 3 //// printf(" ts_s2b_debug.fifo = %d ",(int)ts_s2b_debug.fifo); 193 3 if(ts_Urec[D_UART1].fifo > 0) 194 3 {ts_Urec[D_UART1].fifo = 0; 195 4 ts_Urec[D_UART1].ok = 1;/// 接收到的数据结束 : 总线空闲+buf非空 196 4 ts_Urec[D_UART1].sp = ts_Urecbuf.r1; 197 4 //// L1_uartD_sendArray((U8 *)ts_debug_rec.filter, 5); 198 4 /******* 199 4 L1_uartD_sendArrayhex((U8 *)&ts_debug_rec.filter, 5); 200 4 ts_debug_rec.filter = 0x31; 201 4 ts_debug_rec.R1 = 0x32; 202 4 ts_debug_rec.R2 = 0x33; 203 4 ts_debug_rec.R3 = 0x34; 204 4 ts_debug_rec.ocr = 0x35; 205 4 206 4 L1_uartD_sendArrayhex((U8 *)&ts_debug_rec.filter, 5); 207 4 *********/ 208 4 209 4 } 210 3 } 211 2 ts_Urec[D_UART1].overtime_t ++; 212 2 } 213 1 } 214 215 216 /************************************************* 217 UART 中断 218 *************************************************/ 219 void INTERRUPT_UART(void) D_SERVE_UART 220 { 221 1 if(L0_uart1_IntRI()) //如果是U0接收中断 222 1 { 223 2 L0_uart1_IntRIClear(); //清除接收中断标志 224 2 /// D_LED1_REV(); 225 2 226 2 ///>>>>>>>>>>>>>接收协议 可以更改为其他协议>>>>>>>>>>>>>>>>>>>>>>>> 227 2 ts_Urec[D_UART1].reg = L0_uart1_get(); 228 2 ts_Urec[D_UART1].idle = 0; 229 2 ts_Urec[D_UART1].overtime_t = 0;///需要和tick 定时器中的配合 作为接收超时判定 230 2 /// L1_s2b_PH5_debug(&ts_s2b_debug); 231 2 /// L1_s2b_PH5_debug(TS_s2b_debug); 232 2 L1_s2b_road(D_UART1); 233 2 ///<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 234 2 } 235 1 if(L0_uart1_IntTI()) //如果是U0发送中断 236 1 { C51 COMPILER V9.54 MSP_UART1 09/06/2024 14:31:11 PAGE 5 237 2 L0_uart1_IntTIClear(); //清除发送中断标志 238 2 if(ts_Usend[D_UART1].max != ts_Usend[D_UART1].now) 239 2 { 240 3 ///L0_uartN_set(uNum1,ts_uart[uNum1].p->p[ts_uart[uNum1].p->now]); 241 3 L0_uart1_set(ts_Usend[D_UART1].sbuf[ts_Usend[D_UART1].now]); 242 3 ts_Usend[D_UART1].now ++;//发送本包的下一个数据 243 3 } 244 2 else 245 2 { 246 3 ts_Usend[D_UART1].ok = D_ready; 247 3 ts_Usend[D_UART1].max = 0; 248 3 ts_Usend[D_UART1].now = 0;//可以发送下一包数据 249 3 #if (D_UART1_485_TYPE != TYPE_485_NONE) D_UART1_485_RX() //切换到接收状态 ///gfgfgfh #endif 253 3 } 254 2 } 255 1 //NOP(); NOP(); NOP(); 256 1 } 257 258 ///L2_callback_uart1_free(&s_uart1_rec); 259 #if 0 void L2_callback_uart1_free(Ts_uart_rev_ *p) { ///Ts_uart_rev_ *p = &s_uart1_rec; #define D_s_modbus_min 4 //modbus协议的最小长度 /// D_P24_REV(); ////while(9) D_P24_REV(); if((p->head == 1) && (p->num >= D_s_modbus_min)) { //LED1 ^= 1; p->head = 0; #ifdef D_use_crc crc16qq(p->crc,p->buf,p->num - 2); ////fixme 20220311 ///crc16qq(p->crc,p->buf,p->num - 2); //校验CRC #endif // crc16(p->crc,p->buf,p->num - 2); //校验CRC if(p->crc[0] == p->buf[p->num-2] && p->crc[1] == p->buf[p->num-1]) { p->ok = 1; /// LED0 ^= 1; } p->debugok = 1;////s_uart1_rec.debugok } L1_uart1_isFree_over(); //// D_motor1_FI_rev(); } #endif MODULE INFORMATION: STATIC OVERLAYABLE CODE SIZE = 344 ---- CONSTANT SIZE = 13 ---- XDATA SIZE = ---- ---- PDATA SIZE = ---- ---- C51 COMPILER V9.54 MSP_UART1 09/06/2024 14:31:11 PAGE 6 DATA SIZE = ---- ---- IDATA SIZE = ---- ---- BIT SIZE = ---- ---- EDATA SIZE = ---- ---- HDATA SIZE = ---- ---- XDATA CONST SIZE = ---- ---- FAR CONST SIZE = ---- ---- END OF MODULE INFORMATION. C51 COMPILATION COMPLETE. 2 WARNING(S), 0 ERROR(S)