Page 2 of 2

Re: ADC conversion blocks in osless HAL

Posted: Wed May 04, 2016 9:01 am
by duststorm
Unfortunately it's still locking in the same place.

screenshot of the debugger
screenshot of the debugger


I have copied over the Makefile, mcuconf, halconf, osalconf from the f446re nucleo64 board example, and linked it to the latest trunk version (@9401)
About the only change I made to the mcuconf was setting STM32_ADC_USE_ADC1 to TRUE
and modified halconf to set HAL_USE_ADC to TRUE

I added my test project source.


Do you think it might be an issue with using os-less hal?

Re: ADC conversion blocks in osless HAL

Posted: Wed May 04, 2016 9:31 am
by duststorm
duststorm wrote:Do you think it might be an issue with using os-less hal?


It appears not.

I attached an example using the RT os, it has the same issue.

I made a minimalist example, based very much on the f446re demo, where I try to do an ADC conversion in the main loop.
Doing the conversion makes it block in _idle_thread() indefinitely, and the led stops blinking.
Commenting out the conversion, the led blinks.

Uncomment the line #define USE_TEST_THREAD in main.c to run the blinker from a thread, otherwise it runs in the main loop.
They both have the same effect. Doing ADC conversion stops the thread indefinitely.

Re: ADC conversion blocks in osless HAL

Posted: Wed May 04, 2016 10:03 am
by Giovanni
Could you try the ADC demo in the ChibiOS /testhal directory?

Giovanni

Re: ADC conversion blocks in osless HAL

Posted: Wed May 04, 2016 10:42 am
by RoccoMarco
Hey,
there are still some uncertainties I have discovered in your project:

Code: Select all

#define ADC1_CH1 0
#define ADC1_CH2 2

static const ADCConversionGroup adccg1 = {
  TRUE,
  ADC_CH_NUM,
  adccb,
  adcerr,
  0,  // CR1
  ADC_CR2_SWSTART, //CR2
  0, // SMRP1
  ADC_SMPR2_SMP_AN0(ADC_SAMPLE_56), ADC_SMPR2_SMP_AN0 (ADC_SAMPLE_56), // SMRP2
  ADC_SQR1_NUM_CH(ADC_CH_NUM), // SQR1
  0, // SQR2
  ADC_SQR3_SQ2_N(ADC1_CH1) | ADC_SQR3_SQ1_N(ADC1_CH2) // SQR3
};


Is quite different from mine.
  • In first place if you intend to use PA0 and PA1 it should be

    Code: Select all

    #define ADC1_CH1 0
    #define ADC1_CH2 1

    Note that there are some beautiful macro already defined which you can use (ADC_CHANNEL_IN0, ADC_CHANNEL_IN1 and so on).
  • In second place

    Code: Select all

      ADC_SMPR2_SMP_AN0(ADC_SAMPLE_56), ADC_SMPR2_SMP_AN0 (ADC_SAMPLE_56), // SMRP2

    here you should receive a warning for struct excess. These bitmasks should be in bitwise OR evenmore you hare setting two time sample rate for the same channel (AN0).
  • You are not using my board files. It is shown clearly in this code

    Code: Select all

      palSetPadMode(GPIOA, GPIOA_PIN0, PAL_MODE_INPUT_ANALOG); // adc channel 0, pa0, adc1 ch1
      palSetPadMode(GPIOA, GPIOA_PIN1, PAL_MODE_INPUT_ANALOG); // adc channel 1, pa1, adc2 ch1

    GPIOA_PIN0 doen't exist anymore. Now there is GPIOA_ARD0

I can continue but saving my time and your I have tested ADC official demo on the STM32F446 Nucleo64 here attached. :mrgreen:
It works on trunk. Of course check the CHIBIOS path when you will use it. I have noticed you are not working on ChibiStudio. Otherwise just copy it in workspace_trunk an import it.

I am marking this like solved. Let me know if it isn't.
Ciao,
RM

Re: ADC conversion blocks in osless HAL

Posted: Wed May 04, 2016 11:01 am
by duststorm
Okay, thanks. I'll have a try.

RoccoMarco wrote:[*]You are not using my board files. It is shown clearly in this code

Code: Select all

  palSetPadMode(GPIOA, GPIOA_PIN0, PAL_MODE_INPUT_ANALOG); // adc channel 0, pa0, adc1 ch1
  palSetPadMode(GPIOA, GPIOA_PIN1, PAL_MODE_INPUT_ANALOG); // adc channel 1, pa1, adc2 ch1

GPIOA_PIN0 doen't exist anymore. Now there is GPIOA_ARD0[/list]

I am, but I added these two defines to mcuconfig.h to minimise changes to my code.


RoccoMarco wrote:I have noticed you are not working on ChibiStudio. Otherwise just copy it in workspace_trunk an import it.

That's correct, I'm developing on linux using a gcc and openocd toolchain.

Re: ADC conversion blocks in osless HAL

Posted: Wed May 04, 2016 11:28 am
by RoccoMarco
Ok, I await a response. Good work
Ciao,
RM

Re: ADC conversion blocks in osless HAL

Posted: Wed May 04, 2016 5:36 pm
by duststorm
It seems to work now! :)
Apparently I did not fully understand these configuration bits yet. I think I got the hang of them now.
Thank you for helping me out!

It's also working without OS.