Content originally posted in LPCWare by fmiku on Wed Mar 02 04:38:42 MST 2016
Hello,
I have a question about the XXX_PARAM_T structures.
When I using a interrupt driven functions like "LPC_UARTD_API->uart_get_line(HostUartHandle, ¶m)"
the param structure's data must be keep until the "Done" callback functions are called ?
or the ROM functions makes a own copy of these data into the "xxxHandleMEM[];"
so my problem is the following:
I using the following function to start a UART transmission.
static void host_start_tx (uint8_t *buff, uint16_t size)
{
UART_PARAM_T param;
param.buffer = buff;
param.size = Txsz = size;
/* Interrupt mode, do not append CR/LF to sent data */
param.transfer_mode = TX_MODE_BUF_EMPTY;
param.driver_mode = DRIVER_MODE_INTERRUPT;
/* Setup the transmit callback, this will get called when the
transfer is complete */
param.callback_func_pt = (UART_CALLBK_T) HostTxCB;
/* Transmit the data using interrupt mode, the function will
return */
SET_FLAG(F1, F1_HOST_TX_PEND);
if (LPC_UARTD_API->uart_put_line(HostUartHandle, ¶m)) {
SET_FLAG(Err1, E1_HOST_USART);
CLR_FLAG(F1, F1_HOST_TX_PEND);
// deinit here ??
}
}
Most of time works fine but somtime the transmitted data become corrupted.
I Traced a little in the debugger, some of the params's parameters (CB fns, etc) are seems to be copied to the UARTHandleMEM[] by the ROM API calls but some like data pointer is not.
so in this case the UART_PARAM_T must be allocated in the global RAM space ?
In this case after calling the ROM api the param structure's data may become "unknow/corrupted" because the variable is created on the stack when the function was called, and released when the controll leaves the function.
I have similatr problem with the I2C ROM api too :)