We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
In the 2012-04-25 version of the LPC407x_8x_177x_8x.h that came with my recent download of the MDK ARM tools I discovered something odd about the definitions of some fields for the UART type definitions. Specifically, for UART types 0 and 1 the transmit holding register is an 8-bit value, but for UART type 4 it's a 32-bit value. I don't see any difference in the datasheet for these registers. The difference caused an issue for when creating a class member variable that pointed to this register; or rather, when assigning values to it using the header file.
For reference, this variables were declared in my class,
volatile uint8_t * pTHR; // ptr to MCU UART transmit holding register volatile uint32_t * pIER; // ptr to MCU UART interrupt enable register
but to make the compiler happy I had to do this in setup code for this class.
// save values needed for ISR and read/write methods if(info->comport==0){ nIntNum=UART0_IRQn; pTHR = &LPC_UART0->THR; pIER = &LPC_UART0->IER; }else if(info->comport==1){ nIntNum=UART1_IRQn; pTHR = &LPC_UART1->THR; pIER = &LPC_UART1->IER; }else if(info->comport==2){ nIntNum=UART2_IRQn; pTHR = &LPC_UART2->THR; pIER = &LPC_UART2->IER; }else if(info->comport==3){ nIntNum=UART3_IRQn; pTHR = &LPC_UART3->THR; pIER = &LPC_UART3->IER; }else if(info->comport==4){ nIntNum=UART4_IRQn; // This THR is defined differently in the KEIL supplied header, but not the data sheet. // Not sure why that is. You can only write 8-bit values to the THR. pTHR = (volatile uint8_t *)&LPC_UART4->THR; pIER = &LPC_UART4->IER; }else{ return false; }
Can anyone tell me why the THR for UART4 is defined as a 32-bit value, but all other UART THRs are defined as 8-bit values?
Thanks.
Is it a Keil file, or from NXP?
(whose name is in the copyright?)