#define TX 0x08 #define RX 0x04 #define RIE 0x20 void InitSCI0(void){ SCI0BDH= 0x00; // SCI Baud Rate Registers (SCIBDH and SCIBDL) // calculating the baud rate is: SCI baud rate = SCI // module clock / (16 x BR) SCI0BDL= 26; // SCI Baud Rate Registers (SCIBDH and SCHBDL) // Bit 7 6 5 4 3 2 1 0 // SBR7 SBR6 SBR5 SBR4 SBR3 SBR2 SBR1 SBR0 // 26 -> 19200 Baudrate at Bus Clock 8MHz SCI0CR1= 0x00; // SCI Control Register 1 (SCICR1); 8N1 SCI0CR2= 0x00; // SCI Control Register 2 (SCICR2)}void SetSCI0(char OnOff){ SCI0CR2= OnOff; // SCI Control Register 2 (SCICR2)}void PutcharSCI0(unsigned char cPut){ while( !(SCI0SR1 & 0x80) ); SCI0DRL= cPut;}void PutStSCI0(unsigned char *strPut){ while (*strPut != 0) { while ( !(SCI0SR1 & 0x80) ); SCI0DRL = *strPut++; }}InitSCI0();SetSCI0(RX|TX);PutcharSCI0('3'); <- That works, sending one character Hyperterminal receives the 3 PutStSCI0("Send Text"); <- That does not work Hyperterminal does not receive anything It stopps at this line: while(!(SCI0SR1 & 0x80));
Have to ask, you do have SCISR1 declared as volatile, otherwise the compiler may optimize to only read it once. Have a look at the dissasembly.
Just for grins put a timing delay of just over one byte time between each character send, see what happens.
Beyond that, reading the data sheet for the MC9S12C, it says that TDRE is 0 coming out of reset (non-empty) so this should stop your first character sending! This is the opposite to the behaviour on the 08's. I have rev 1.20 of the data sheet, I see the current on-line version still maintains that fact.
If you are using Codewarrior, have you tried using the beans? Saves all this low level stuff...
Hello,
thank you very much! It seems to work fine now. I do not know what was wrong! I started a new project to test sci and now it seems to work fine. I really do not know what was wrong.
Thank you very much!
Best regards