We are trying to use RA0E1 in a commercial project,ADC12 module is working without problems so far starting our application via hal_entry() (without ThreadX).
But using ADC12 in a ThreadX project always leads to a BSP_CFG_HANDLE_UNRECOVERABLE_ERROR in the Default_Handler().For verifying the cause I stripped everything back to a "bare metal" ThreadX project (New Renesas C/C++ project with Azure ThreadX => Minimal => Add New thread).
Without adding an initial R_ADC_D_Open the single/only thread runs fine with regular APP_PRINT output on an RTT Viewer terminal.
After adding/activating an initial R_ADC_D_Open(&g_adc0_ctrl, &g_adc0_cfg) (see code below)
#include "new_thread0.h"
#include "common_utils.h"
#include "r_adc_d.h"
extern adc_d_instance_ctrl_t g_adc0_ctrl;
extern const adc_cfg_t g_adc0_cfg;
/* New Thread entry function */
void new_thread0_entry(void)
{
fsp_err_t err = FSP_SUCCESS; // Error status
err = R_ADC_D_Open(&g_adc0_ctrl, &g_adc0_cfg);
/* handle error */
if (err != FSP_SUCCESS)
APP_ERR_PRINT("** R_ADC_D_Open API failed ** \r\n");
}
while (1)
APP_PRINT("\r\nMain thread running ...");
tx_thread_sleep (200);
R_ADC_D_Open always returns FSP_SUCCESS but immediately thereafter ThreadX runs into the exception shown below:/*******************************************************************************************************************//** * Default exception handler. **********************************************************************************************************************/BSP_SECTION_FLASH_GAP void Default_Handler (void){ /** A error has occurred. The user will need to investigate the cause. Common problems are stack corruption * or use of an invalid pointer. Use the Fault Status window in e2 studio or manually check the fault status * registers for more information. */ BSP_CFG_HANDLE_UNRECOVERABLE_ERROR(0);}Playing around with several stack constellations (raising Thread Stack size, Timer Thread Stack, Main stack and Heap size) did not help.
The same problem occures also, when further code for ADC sampling is added, then always ONE correct ADC measurement is done but immediately thereafter program/thread execution runs into the same exception.
Can anybody help ?