Hello. I'm trying to use the SCI1 on my 56F807 to do a simple 9-bit protocol address-wakeup communication. However, I seem to be having problems with getting the baud rate correct. With the following code: ---------------- SciConfig.SciCntl = SCI_CNTL_WORD_9BIT | SCI_CNTL_PARITY_NONE | SCI_CNTL_LOOP_NO| SCI_CNTL_ENABLE_IN_WAIT| SCI_CNTL_WAKE_BY_ADDRESS; SciConfig.SciHiBit = SCI_HIBIT_0; SciConfig.BaudRate = SCI_USER_BAUD_RATE_1; //def as 10 Sci9FD = open(BSP_DEVICE_NAME_SCI_1, O_RDWR | O_NONBLOCK, & (SciConfig)); ioctl( Sci9FD, SCI_DATAFORMAT_EIGHTBITCHARS, NULL ); /* NonBlocking Read and Write */ ioctl( Sci9FD, SCI_CALLBACK_EXCEPTION, NULL ); //no error handling ioctl( Sci9FD, SCI_CALLBACK_RX,sci_9bit_rx ); ioctl( Sci9FD, SCI_CALLBACK_TX, sci_9bit_tx); sci_rx_len=1; //callback on every rx char ioctl( Sci9FD, SCI_SET_READ_LENGTH, (void *)&sci_rx_len ); ------------------ I get a baud rate that is far too low for 250,000 baud, which I should get with my IP Bus Freq@,000,000 and SCI_USER_BAUD_RATE_1. However, If I make a subsequent call: periphMemWrite(10, &ArchIO.Sci1.BaudRateReg); The rate looks correct and the SCI seems to receive bytes ok. However it fails to identify the address bytes (set by the 9th bit). I sniff for these by issuing: ioctl( Sci9FD, SCI_CMD_WAIT, NULL ); and when I next enter my sci rx callback, I assume that the received byte is an address byte. However, this rarely happens. Does anyone have any insight or experience with this? Thank you. -Aaron Aaron Edsinger Living Machines Group MIT Artificial Intelligence Lab |
SCI baud rate/9 bit protocol
Started by ●August 14, 2003