//Sending "YES" to Hyperterminal (or Tera Terminal) via Serial Com0 (SCI0) on HCS12G128 Tower board (TWR-S12G128) //On TWR-S12G128 Serial COM0 (SCI0) is IDC 2x5 male header located next to brown POT. //The TWR-S12G128 board comes with a DB9-to-IDC-2x5 femal cable for connecting it to the COM port of x86 PC //When connecting female IDC 2x5 to Tower,make sure pin 1 on IDC Tower board is lined up with the red stripe of the IDC-2x5 cable //If the IDC-2x5 cable is connected right, then RED stripe will be on side of USB power cable //If your x86 PC does not have Serial COM port (with DB-9 connector)then you need USB to Serial Converter // The best one we have seen is (TRENDnet USB to RS-232 Serial Converter TU-S9) from Amazon //http://www.amazon.com/TRENDnet-RS-232-Serial-Converter-TU-S9/dp/B0007T27H8/ref=pd_bxgy_e_img_y //Modified and tested by Mazidi from Example 10-9C in HCS12 textbook by Mazidi & Causey //In Codewarrior, make sure you are in Open Source BDM //In Codewarrior F7(make), F5(Debug) and F5 again to start running //Bring up HyperTerminal in Windows XP (or Tera Term in Windows Vista and Windows 7) //and you will see YES appears on x86 PC screen //The HCS12G128 Tower works at 6.25 MHz Bus Freq. #include /* common defines and macros */ #include "derivative.h" /* derivative-specific definitions */ void SerTx0(unsigned char); void main(void) { PER0AD = 0x80; // enable PU on PAD15 to enable COM for the HCS12G128 chip //Notice this is different from HCS12DP256/512 SCI0BDH=0x00; SCI0BDL=41; //12.5 MHz/2=6.25MHz, 6.25MHz/16=390,625 Hz and 390,625/9600=41 SCI0CR1=0x00; SCI0CR2=0x0C; for(;;) { SerTx0('Y'); SerTx0('E'); SerTx0('S'); SerTx0(' '); } } void SerTx0(unsigned char c) //SCI0 (COM0 of HCS12 chip) { while((SCI0SR1 & 0x80)==0); //make sure the last bit is gone SCI0DRL=c; //before giving it another byte }