| ??? 11/21/07 04:15 Read: times |
#147288 - UART SBUF Write Issues LPC9XX |
Hello all,
When no output was measured while testing to see if the UART TXD was writing characters out with the help of Kiel's CodeArchitect for a p89lpc935, I tried setting a value to SBUF and then checking the output via an LCD. Using a sample code as a base found on codearchitect.org, I have reached the current point and am not sure where to go from here. SBUF is currently never set to the value passed into the uart_transmit() function. If anyone can help it would be greatly appreciated. Thanks, /**************************************************************** UART Program Code ***************************************************************/ include "reg932.h" void main(){ uart_init(); forever{ uart_transmit('Z'); } } /******************************************************************* DESC: Initializes UART for mode 1 Baudrate: 9600 RETURNS: Nothing CAUTION: If interrupts are being used then EA must be set to 1 after calling this function ************************************************************************/ void uart_init ( void ) { // configure UART // clear SMOD0 PCON &= ~0x40; SCON = 0x50; // set or clear SMOD1 PCON &= 0x7f; PCON |= (0 << 8); SSTAT = 0x80; // configure baud rate generator BRGCON = 0x00; BRGR0 = 0xD2; BRGR1 = 0x04; BRGCON = 0x03; // initially not busy mtxbusy = 0; // set isr priority to 0 IP0 &= 0xEF; IP0H &= 0xEF; // enable uart interrupt ES = 1; } // uart_init /*********************************************************************** DESC: UART Interrupt Service Routine RETURNS: Nothing CAUTION: uart_init must be called first EA must be set to 1 ************************************************************************/ void uart_isr ( void ) interrupt 4 using 1 { if (RI) { // clear interrupt flag RI = 0; } // if if (TI) { // clear interrupt flag TI = 0; // no longer busy mtxbusy = 0; } // if } // uart_isr /*********************************************************************** DESC: Transmits a 8-bit value via the UART in the current mode May result in a transmit interrupt if enabled. RETURNS: Nothing CAUTION: uart_init must be called first ************************************************************************/ void uart_transmit ( unsigned char value // data to transmit ) { mtxbusy = 1; while(mtxbusy){ SBUF = value; LcdClear(); LcdWriteString("Writing SBUF Value"); if (SBUF != value){ LcdWriteCmd(0x0C0); LcdWriteString("SBUF Value: "); LcdWriteChar(SBUF); LcdWriteString(" Not Equal to "); LcdWriteChar(value); } } } // uart_transmit /*********************************************************************** DESC: Gets a received 8-bit value from the UART RETURNS: Received data CAUTION: uart_init must be called first ************************************************************************/ unsigned char uart_get ( void ) { return SBUF; } // uart_get |
| Topic | Author | Date |
| UART SBUF Write Issues LPC9XX | 01/01/70 00:00 | |
| Clarification please | 01/01/70 00:00 | |
| Basics | 01/01/70 00:00 | |
| I believe that's his problem, ... | 01/01/70 00:00 | |
| UART SBUF Write Issues LPC9XX | 01/01/70 00:00 | |
UART ? | 01/01/70 00:00 |



