Hi,
I am writing a code to use UART to transmit a certain character and display it on the PC with the MC13213-SRB board. It is kind of a simple code, however what I got from the PC are just junky code that were unreadable. The following is a general description of my codes:
first of all, I defined the SCI port I will use to communicate:
#define SCID SCI2D#define SCIS1_TDRE SCI2S1_TDRE#define SCIS1_TC SCI2S1_TC
Then in the main loop, the codes are:
void main(void) { MCUInit(); for (;;){ while (!SCIS1_TDRE); SCID = 'f'; while (!SCIS1_TC); } In the MCU initialization part I define the control register for SCI and for the CPU clock to figure out the baurdrate:
void MCUInit(void){ SOPT = 0x72; /* Turn off the watchdog. */ SPMSC1 = 0x1C; SPMSC2 = 0x00; ICGC1 = 0x44; ICGC2 = 0x00; /* Common initialization of the CPU registers */ /* PTASE: PTASE7=0,PTASE6=0,PTASE5=0,PTASE4=0,PTASE3=0,PTASE2=0,PTASE1=0,PTASE0=0 */ PTASE = 0x00; /* PTBSE: PTBSE7=0,PTBSE6=0,PTBSE5=0,PTBSE4=0,PTBSE3=0,PTBSE2=0,PTBSE1=0,PTBSE0=0 */ PTBSE = 0x00; /* PTCSE: PTCSE7=0,PTCSE6=0,PTCSE5=0,PTCSE4=0,PTCSE3=0,PTCSE2=0,PTCSE1=0,PTCSE0=0 */ PTCSE = 0x00; /* PTDSE: PTDSE7=0,PTDSE6=0,PTDSE5=0,PTDSE4=0,PTDSE3=0,PTDSE2=0,PTDSE1=0,PTDSE0=0 */ PTDSE = 0x00; /* PTESE: PTESE7=0,PTESE6=0,PTESE5=0,PTESE4=0,PTESE3=0,PTESE2=0,PTESE1=0,PTESE0=0 */ PTESE = 0x00; /* PTFSE: PTFSE7=0,PTFSE6=0,PTFSE5=0,PTFSE4=0,PTFSE3=0,PTFSE2=0,PTFSE1=0,PTFSE0=0 */ PTFSE = 0x00; /* PTGSE: PTGSE7=0,PTGSE6=0,PTGSE5=0,PTGSE4=0,PTGSE3=0,PTGSE2=0,PTGSE1=0,PTGSE0=0 */ PTGSE = 0x00; /* ### Init_SCI init code */ SCI2BDH = 0x00; SCI2BDL = 0x35; SCI2C1 = 0x00; SCI2C2 = 0x28; SCI2C3 = 0x00; asm CLI; /* Enable interrupts */} So with those codes | should get character 'f' repeatly displayed on my PC. I try to tune the transmit buardrate in SCIBDL, However I still got the unreadable code on my PC. Is this because the code: SCID='f'; is wrong or because of the wrong initialization?
Thanks