rs 485 bus

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

rs 485 bus

10,897 次查看
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
标签 (1)
0 项奖励
回复
22 回复数

427 次查看
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 项奖励
回复

427 次查看
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 项奖励
回复