??? 09/25/09 10:27 Read: times |
#169127 - I have only seen some in assembly Responding to: ???'s previous message |
The only 8051-specific bit about it is writing to & reading from SFRs - and translating SFR accesses in assembler to SFR accesses in 'C' is trivial; eg, from the "Simple RS232 Guide" in the FAQs:
SERINIT: ;Initialize serial port CLR TR1 CLR TI CLR RI MOV SCON,#01011010B ;TI SET INDICATES TRANSMITTER READY. ;MODE 1 REN MOV TMOD,#00100001B ;TIMER 1 MODE 8 BIT AUTO RELOAD MOV TH1,#0FDH ;TIMER RELOAD VALUE SETB TR1 ;START TIMERbecomes: void serinit( void ) { TR1 = 0; TI = 0; RI = 0; SCON = 0x5A; TMOD = 0x21; TH1 = 0xFD; TR1 = 1; } I'll leave you to properly comment it, and do something about the "magic numbers"... See your Keil manuals for specific language extensions for checking & clearing bits... |