rs 485 bus

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

rs 485 bus

6,234 Views
DanielMorley
Contributor I
I am trying to recieve a message via the Uart for a MC9S08GT16A.  The following code is my attempt to read a line of text and send it out.  I cannot seem to find any indication that I am recieving data.  
 
 
 
 void RecMsg() {
 byte ix=0;    // String pointer
 byte dummy;    // dummy var for reading SCIS1
 byte nxt_char;
 char msg[8] ;
    SEREN == OFF ;
  SCI1C2_RE = 1;    // enable Rx
 
        
 dummy = SCI1S1;   // 1st half of TDRE clear procedure
 msg[ix++] = dummy;
 while( msg[ix++] != 0x00) {
   nxt_char =SCI1D ; // 2nd half of TDRE clear procedure
    msg[ix++]=nxt_char ;
   while(!SCI1S1_TDRE){
     feedCOP();
   };
 } //end while((SCI1D
 while(!SCI1S1_TC){
   feedCOP();
 };
 if(ix>>1)
 SendMsg(msg);
 
 SCI1C2_TE = 0;
  
} //end RecMsg
Labels (1)
0 Kudos
22 Replies

120 Views
DanielMorley
Contributor I
No It is changed and that is not it. I am confused on why a simple send SCI1D to the serial port is still giving me a 000.  I cann't see how it could be a hardware issue.  The recieve port is getting the signal.  Could it be something in sendmessage routine?
 
 

  
 void SendMsg(char msg[]) {
 byte ix=0;    // String pointer
 byte dummy;    // dummy var for reading SCIS1
 byte nxt_char;
 
 SCI1C2 = 0x08;    // enable Tx
 dummy = SCI1S1;   // 1st half of TDRE clear procedure
 nxt_char = msg[ix++];
 while(nxt_char != 0x00) {
   SCI1D = nxt_char; // 2nd half of TDRE clear procedure
   nxt_char = msg[ix++];
   while(!SCI1S1_TDRE){
     feedCOP();
   };
 } //end while((SCI1D
 while(!SCI1S1_TC){
   feedCOP();
 };
 SCI1C2_TE = 0;
} //end SendMsg
 
0 Kudos

120 Views
rocco
Senior Contributor II
oh . . . ok . . .

It's hard for me to debug when I'm not looking at the right code . . :smileywink:

If that is not how the buffer is now defined, how is it defined now? Are you sure the receive and transmit routine are using the same buffer? What is the scope of the new buffer? Are the two routines in the same source file? (I assume so).
0 Kudos