I am using KSDK 1.3.0, Processor Expert, custom PCB with MK02FN64VLH10 controller.
I've been trying to get the com port working for 2 days now...I need some guidance..
Used PE to set up the uart and the program crashes when executing this:
UART_DRV_SendData(0,&data,1u);
After a day and a half, I deleted all the PE stuff, and copied the example from the drivers examples\uart\uart_non_blocking/main.c
Set some definitions / variables, and compiles fine, but it crashes at the same code, UART_DRV_SendData...
Here is the code I copied from the example, the line it crashes on (step over and never returns) ends with ##########
int Uart_Setup(void) // this was main..
{
uint8_t rxChar, txChar;
uint32_t byteCountBuff = 0;
// Initialize variable uartState of type uart_state_t
uart_state_t uartState;
// Fill in uart config data
const uart_user_config_t uartConfig = {
.bitCountPerChar = kUart8BitsPerChar,
.parityMode = kUartParityDisabled,
.stopBitCount = kUartOneStopBit,
.baudRate = 38400
};
// Enable clock for PORTs, setup board clock source, config pin
hardware_init();
// Initialize the uart module with base address and config structure
UART_DRV_Init(BOARD_DEBUG_UART_INSTANCE, &uartState, &uartConfig);
// Inform to start non blocking example
byteCountBuff = sizeof(buffStart);
UART_DRV_SendData(BOARD_DEBUG_UART_INSTANCE, buffStart, byteCountBuff); // crashes here #########
// Wait until transmission is finished
while (kStatus_UART_TxBusy == UART_DRV_GetTransmitStatus(BOARD_DEBUG_UART_INSTANCE, NULL)){}
// Inform user of what to do
byteCountBuff = sizeof(bufferData1);
UART_DRV_SendData(BOARD_DEBUG_UART_INSTANCE, bufferData1, byteCountBuff);
// Wait until transmission is finished
while (kStatus_UART_TxBusy == UART_DRV_GetTransmitStatus(BOARD_DEBUG_UART_INSTANCE, NULL)){}
while(true)
{
// Call received API
UART_DRV_ReceiveData(BOARD_DEBUG_UART_INSTANCE, &rxChar, 1u);
// Wait until we receive a character
while (kStatus_UART_RxBusy == UART_DRV_GetReceiveStatus(BOARD_DEBUG_UART_INSTANCE, NULL)){}
// Echo received character
txChar = rxChar;
UART_DRV_SendData(BOARD_DEBUG_UART_INSTANCE, &txChar, 1u);
}
}
FYI.
Crashes in startup_MK02F12910.s at the below line when I pause
| b DefaultISR // ################ always is here when I pause |
| .size DefaultISR, . - DefaultISR |
| /* | Macro to define default handlers. Default handler |
| * | will be weak symbol and just dead loops. They can be |
| * | overwritten by other handlers */ |
| .macro def_irq_handler handler_name |
| .weak \handler_name |
| .set \handler_name, DefaultISR |
| .endm |