AnsweredAssumed Answered

Serial Reception Issue

Question asked by Jonathan Abbatiello on Jun 30, 2011
Latest reply on Jul 6, 2011 by Jonathan Abbatiello

Hello my friends!

 

I am trying to set some serial communication to ultimately read data from a GPS module, but I am attempting to link two identical microcontrollers together first to ensure that I can properly send( which I have already verified via hyperterminal) and receive, which is what I am unable to do so far. I am working with the MC9S12DG128 microcontroller and my code is as follows, you will notice that I am going to be utilizing my LCD display within this communication as well. Please let me know if there is anything you see that may be the issue:

 

void output_string(int cmd);void outcmd(unsigned char command);void clear (void);void output1(int op);void LCD_init (void);int read;int test;int in; void main(void) {DDRS = 0x08;PTS = 0x00;DDRH = 0xFF; LCD_init ();SCI0BD = 0x68;SCI0CR1 = 0x00;  // CHANGE BACK TO SCI0SCI0CR2 = 0x2C;SCI0DRH = 0x00; // Ensure T8 = 0 (8-bit mode)    EnableInterrupts;//SCI0CR2_RE = 0;output_string (33); // ASCII Characters !GPS, used to request information/*output_string (71);output_string (80);output_string (83);output_string (5); // Data selection line, see chart for details *///SCI0CR2_RE = 1; while(1){      PTH = SCI0DRL;     read = SCI0SR1;    in = SCI0DRL;    output1 (in);  }  for(;;) {    _FEED_COP(); /* feeds the dog */  } /* loop forever */  /* please make sure that you never leave main */}void output_string (int cmd) {          read = SCI0SR1; // Used to clear flag which must be read to do so.      while (SCI0SR1_TDRE == 0);      SCI0DRL = cmd;      while (SCI0SR1_TC ==0);}#pragma CODE_SEG __NEAR_SEG NON_BANKED void interrupt 20 SCI_ISR (void){  //while(SCI0SR1_RDRF == 1){    PTH = SCI0SR1;     read = SCI0SR1;    in = SCI0DRL;    output1 (in);     //in++;  }#pragma CODE_SEG DEFAULTvoid outcmd(unsigned char command){  unsigned int z;  PTS = 0xF0 & command;  PORTE_BIT4 = 0;  PORTE_BIT4 = 1;  PORTE_BIT4 = 0;   PTS = 0xF0 & (command<<4);  PORTE_BIT4 = 0;  PORTE_BIT4 = 1;     PORTE_BIT4 = 0;  for(z=0;z<=6666;z++);   }void clear(void){    outcmd(0x01);  outcmd(0x02);  }void output1(int op){  unsigned int x;    PORTE_BIT7 = 1;  //while(*op)  //{   // while there is contents available       PTS = 0xF0 & op;  PORTE_BIT4 = 0;  PORTE_BIT4 = 1;  PORTE_BIT4 = 0;  for(x=0;x<=4;x++);   PTS = 0xF0 & (op<<4);  PORTE_BIT4 = 0;  PORTE_BIT4 = 1;  PORTE_BIT4 = 0;  for(x=0;x<=6666;x++);  //op ++;  //} }void LCD_init (void) {  unsigned int z;                                                 DDRS = 0xFF;DDRE = 0xFF;PORTE_BIT7 = 0;PTS = 0x00;for (z=0;z<=33333;z++); // 50ms wait specified by manufactuer to ensure LCD voltage level moves up to proper power level for (z=0;z<=33333;z++);PTS = 0x30;for (z=0;z<=6666;z++);PTS = 0x30;for (z=0;z<=213;z++);PTS = 0x30;for (z=0;z<=213;z++);PTS = 0x20;  // 4 - bit initialization PORTE_BIT4 = 0; // Toggle enable to process data PORTE_BIT4 = 1;PORTE_BIT4 = 0;for(z=0;z<=6666;z++); // 5ms delay outcmd(0x28); // 4-bit 2 line setupoutcmd(0x08); // turn display off clear(); outcmd(0x06); // entry mode set to incriment DDRAM addressoutcmd(0x0F); // Turn display/cursor/blink on}

 

 

 It seems that I am not even generating an interrupt or getting anything to be received into the SCI Data register. Thank you so very much for your time and I greatly appreciate you taking the time look at this posting!

 

Sincerely,

Jonathan

Outcomes