Other Parts Discussed in Thread: SYSBIOS
With help of Clement i was able to debug a hardware exception.
It seems like the system runs into
> Hard Fault: FORCED: BUSFAULT: PRECISERR.Data Access Error. Address = 0x1a19c
Reading out the lr register after adding an exeption handler hook and disabling buffered writing shows a return address in ti_sysbios_knl_Semaphore_post__E.
The fault seems to happen inside the UART logging functionality, more specifically UART_close(), see code below for UART setup and print functions.
#include <ti/drivers/UART.h>
#include <ti_drivers_config.h>
#include <lovelyLogging/src/lovelyLogging.h>
#define UART_BUFFER_SIZE 200
char uart_output_buffer[UART_BUFFER_SIZE] = {'-'};
static UART_Params params;
void cc26x2_logging_uart_init() {
UART_init();
UART_Params_init(¶ms);
params.baudRate = 115200;
params.readMode = UART_MODE_BLOCKING;
params.writeMode = UART_MODE_BLOCKING;
params.readTimeout = UART_WAIT_FOREVER;
params.writeTimeout = UART_WAIT_FOREVER;
params.readDataMode = UART_DATA_BINARY;
params.writeDataMode = UART_DATA_BINARY;
}
volatile int uart_opened_count = 0;
volatile int uart_closed_count = 0;
volatile int uart_close_attempt_count = 0;
void cc26x2_logging_flush() {
int string_length;
UART_Handle uart = UART_open(CONFIG_UART_0, ¶ms);
if ( NULL == uart ) return;
uart_opened_count++;
while ( 0 == llog_is_empty() ) {
string_length = llog_next_entry_as_string(
uart_output_buffer,
UART_BUFFER_SIZE
);
UART_write(uart, uart_output_buffer, string_length);
}
uart_close_attempt_count++;
UART_close(uart);
uart_closed_count++;
}
Multiple log entries are created and flushed from inside simplePeripheral_init() and right after simplePeripheral_init() returns.
They are all printed to the console. Lets say we have printed n messages at this point.
Then, whatever the next message is after this point, causes a HWI exception as described above.
The system seems to never return from UART_close(), because the debug variables show the following values:
uart_opened_count == n + 1
uart_close_attempt_count == n + 1
uart_closed_count == n
I wonder how I may debug this kind of behaviour to figure out where the exception occurs and why.
All feels like a dig in the dark to me to be honest :/
