ADC With Callback STM32F0 Discovery//Debug Issues

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
JohnL
Posts: 16
Joined: Mon Nov 11, 2013 12:49 am

ADC With Callback STM32F0 Discovery//Debug Issues

Post by JohnL »

I'm not quite sure what is going on here
I have a shell which is spawning a adc thread. If i set it to synchronous with no callback, the code executes, however when adding a callback the program crashes on adcStartConversion.

Code: Select all

#define ADC_GRP1_NUM_CHANNELS   1
#define ADC_GRP1_BUF_DEPTH      8

#define ADC_GRP2_NUM_CHANNELS   4
#define ADC_GRP2_BUF_DEPTH      16

static const ADCConversionGroup adcgrpcfg1 = {
    FALSE,
    ADC_GRP1_NUM_CHANNELS,
    adcTempCallBack,
    adcErrorCallBack,
    ADC_CFGR1_RES_12BIT,                              /* CFGRR1 */
    ADC_TR(0, 0),                                     /* TR */
    ADC_SMPR_SMP_1P5,                                 /* SMPR */
    ADC_CHSELR_CHSEL10                                /* CHSELR */
};




void hello(void)
{
chprintf((BaseSequentialStream*)&SD1, "5787766");
}

void adcTempCallBack(ADCDriver *adcp, adcsample_t *buffer, size_t n)
{
        hello();
        (void)adcp;
        hello();

}

 void adcErrorCallBack(ADCDriver *adcp, adcerror_t err) {
chprintf((BaseSequentialStream*)&SD1, "Hello World17");
chThdSleepMilliseconds(500);
    (void)adcp;
    (void)err;
}



Also- I am using os x, stm32f0 discovery, st-util and arm-eabi-none I cannot get the program to run through gdb. It loads fine however i need to unplug the device to see the program run. (which kills the debug connection)

Code: Select all

(gdb) tar ext :4242
Remote debugging using :4242
0x08000240 in ?? ()
(gdb) load ./build/ch.elf
Loading section startup, size 0xc0 lma 0x8000000
Loading section .text, size 0x2db4 lma 0x80000c0
Loading section .data, size 0x1c lma 0x8002e78
Start address 0x8000240, load size 11920
Transfer rate: 7 KB/sec, 3973 bytes/write.
(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: 
0x2000002e in ?? ()
(gdb)


Thanks
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: ADC With Callback STM32F0 Discovery//Debug Issues

Post by Giovanni »

Hi,

Callbacks are called from ISR context, you cannot chprintf() to streams from there. From ISR context you can only use I-class functions, please refer to the "kernel concepts" section in the kernel documentation.

Giovanni
JohnL
Posts: 16
Joined: Mon Nov 11, 2013 12:49 am

Re: ADC With Callback STM32F0 Discovery//Debug Issues

Post by JohnL »

Thank you, I'll try that out.
JohnL
Posts: 16
Joined: Mon Nov 11, 2013 12:49 am

Re: ADC With Callback STM32F0 Discovery//Debug Issues

Post by JohnL »

You were right. thanks
Post Reply