For remaining debug ports and using uart, we are trying to use UART0 with ALT2 : P1
1. We comment out the "HAL_UART_DMA" definition in
Hal_board_cfg.h
to make sure we are using "HAL_UART_ISR=1"
2. We modified the _hal_uart_isr.c ==>
#if (HAL_UART_ISR == 1)
/*
#define PxOUT P0
#define PxDIR P0DIR
#define PxSEL P0SEL
*/
/* We are using uart0 alt2, so we uses port1 */
#define PxOUT P1
#define PxDIR P1DIR
#define PxSEL P1SEL
...
#endif
#if (HAL_UART_ISR == 1)
#define HAL_UART_PERCFG_BIT 0x01 // USART0 on P0, Alt-1; so clear this bit.
/* Holmas : For maintain debug port as well as uart port, we use uart0 alt2 on p1*/
/*
#define HAL_UART_Px_RX_TX 0x0C // Peripheral I/O Select for Rx/Tx.
#define HAL_UART_Px_RTS 0x20 // Peripheral I/O Select for RTS.
#define HAL_UART_Px_CTS 0x10 // Peripheral I/O Select for CTS.
*/
#define HAL_UART_Px_RX_TX 0x30 // Peripheral I/O Select for Rx/Tx. We are using P1 pin 4,5
#define HAL_UART_Px_RTS 0x08 // Peripheral I/O Select for RTS.
#define HAL_UART_Px_CTS 0x04 // Peripheral I/O Select for CTS.
#else
...
#endif
3. We invoked the uart initialization functionas HalUARTInit( ) and HalUARTOpen( ) in SimpleBLEPeripheral_Init()
uint8 port = HAL_UART_PORT_0;
halUARTCfg_t conf;
conf.baudRate = HAL_UART_BR_38400;
conf.flowControl = 0;
HalUARTInit();
HalUARTOpen(port, &conf);
We believe that the UART interrupt is enabled in HalUARTOpen( ) with the codes
UxCSR |= CSR_RE;
URXxIE = 1;
UTXxIF = 1; // Prime the ISR pump.
4. Finally, we use the following code to check if there is any receiving data
if ( events & PERIODIC_EVT )
{
uint8 uport = HAL_UART_PORT_0;
uint8 cbuf[256];
uint8 readlen;
// Restart timer
if (PERIODIC_EVT)
osal_start_timerEx( simpleBLEPeripheral_TaskID, PERIODIC_EVT, PERIODIC_EVT_PERIOD );
// Perform periodic application task
performPeriodicTask();
if( Hal_UART_RxBufLen(uport)) {
/* read uart*/
readlen = HalUARTRead(uport, cbuf, sizeof(cbuf));
}
return (events ^ PERIODIC_EVT);
}
5. Now we put the uart tx rx on keyfob test port
1
x x --------> TX ----------------> RX of FDDI
x x FDDI ------------------------- Gnd
x x <--------- RX ---------------- TX of FDDI
x x
x x
TEST
But the interrupt service runtine is never called and the periodic checking is never received any data.
Can you help us to fill the gap we missed ?
Wei