Not receiving data through SCI

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Not receiving data through SCI

2,891件の閲覧回数
Tineras
Contributor I
#include <hcs12dp256.h>#define RDRF 0x20   // Receive Data Register Full Bit#define TDRE 0x80   // Transmit Data Register Empty Bitvoid init_SCI1(void){  SCI1BDH = 0;  SCI1BDL = 156; // baud rate to 9600  SCI1CR1 = 0x20; // 8-N-1  SCI1CR2 = 0x0C;}void init_PB(void) // Setup LEDs for data verification{   DDRB=0xFF;    // Output - Port B (Specifies Direction)  PORTB=0x01;   // Enable Port B0  DDRH|=0x00;   // Input - Port H - Direction of Switches  DDRJ|=0x02;   // Output - PJ1 - Sets an output on Pin 2  PTJ&=0xFD;    // LED Enable - Forces 0 to Pin 2}main(void){  init_PB();  PTJ &= 0xFE;  init_SCI1();      while(1)      {   while((RDRF & SCI1SR1)== 0){}; // RDRF never goes high ???        PORTB = SCI1SR1;  // Trying to display the output on LEDs      }}

I'm using a mc9s12dp256 on a Dragon 12 board.  This is my code for the receiver.  It's just quick and dirty just to receive some data.  This is my first attempt at SCI communication.  I have verified that the transmitter is sending 10 bits of data (start,data,stop).  It is running through the rs485 in single-line mode.  The RDRF bit never shows that the SCI1DRL register is full.  Any insight would be super helpful.
 
Thanks,
Aaron W.
ラベル(1)
0 件の賞賛
返信
5 返答(返信)

958件の閲覧回数
bigmac
Specialist III
Hello Aaron,
 
It is not clear from your code snippet, the manner in which you control the RS485 interface device.  I am not familiar with your Dragon 12 board.  However, for the MCU to receive data, the transmit section of the interface must be disabled, and the receive section enabled, otherwise the SCI won't see any incoming data.
 
It may be useful to check for the presence of data, using an oscilloscope, on each line of the RS485 pair, and at the RXD pin of the MCU.
 
Regards,
Mac
 
0 件の賞賛
返信

958件の閲覧回数
Tineras
Contributor I
I have confirmed the following through RS232 via serial cable:
 
-Transmitter-
Checked output on oscope
Received char from transmitter in hyperterminal
 
-Receiver-
Sent char to receiver from hyperterminal
 
I have also tried to connect the TxD and RxD directly on the chips with no luck.  Both boards are have a common ground.
 
I'm working on making a male to male serial cable right now to check rs232 connection from board to board.
 
Thanks
0 件の賞賛
返信

958件の閲覧回数
bigmac
Specialist III
Hello,
 
I am somewhat confused!
 
Initially you referred to RS485 interface, but now you refer to RS232.  Different drivers, and different voltage levels apply in each case.  Are you using a RS232-to-RS485 adaptor with the PC on which you run hyperterminal?  What device type is used for the RS485 interface on the Dragon 12 board?
 
Since RS485 (on a single pair) is half duplex, your SCI code will need to control the direction in which the RS485 interface operates.  This is not a requirement for RS232 operation.
 
Regards,
Mac
 
0 件の賞賛
返信

958件の閲覧回数
Tineras
Contributor I
I was just switching to the RS232 to verify that communication was at least happening.  Anyway, I figured it out.  I had not set the DDRJ register correctly.  Once I changed J0 to outputs, it worked perfectly.
0 件の賞賛
返信

958件の閲覧回数
Tineras
Contributor I
I managed to get data to the receiver directly by switching the communications jumper to urxd1 on both boards.  I'm still not sure why it won't work through the rs485, but I'm working on it.
0 件の賞賛
返信