SCICR2用那么多clrbit,先直接清个零不就行了。 我贴一段代码你自己对照寄存器的的先后顺序看如何配置实现发送吧: ;16MHzOSC Fosc=16MHz ;Fosc2=8MHz ;PLL Close
;---------------------------- ;Serial Communication Initialization ;Bps: 9600bps .SCI_Init CLR SCICR1 CLR SCICR2 LD A,SCISR ;Clear Flag LD A,SCIDR LD A,#0 LD SCIETPR,A LD A,#0 LD SCIERPR,A LD A,#$0D2 ;9600 ;LD A,#$ ;38400 LD SCIBRR,A LD A,#0 ;8bit LD SCICR1,A LD A,#$08 LD SCICR2,A RET
;------------------------------- ;Serial Send Funication .SCI_Tx LD SCIDR,A .SCI_Wait BTJF SCISR, #7, SCI_Wait RET
调用的时候参数送到A,像下面的一样:
.Debug_Battery_1 LD A, #$AA CALL SCI_Tx LD A, Voltage_1_H CALL SCI_Tx LD A, Voltage_1_No_Counter CALL SCI_Tx LD A, Voltage_1_Yes_Counter CALL SCI_Tx LD A, PWM_1_Pulse CALL SCI_Tx LD A, Battery_1_Status CALL SCI_Tx LD A, Temperature_1 CALL SCI_Tx LD A, Temperature_1_Counter CALL SCI_Tx LD A, Temperature_1_OverProt_Counter CALL SCI_Tx LD A, Battery_1_RTC_H CALL SCI_Tx LD A, Battery_1_RTC_L CALL SCI_Tx LD A, Voltage_1_Check_Counter CALL SCI_Tx LD A, LED_1_Value CALL SCI_Tx LD A, LED_1_Flash CALL SCI_Tx RET
上面得代码是我以前在ST72F324K4B6上用过的。 |