Page 1 of 2
STM32F100 on STM32VL Discovery - Simple ADC voltage measure
Posted: Mon Nov 17, 2014 9:27 pm
by bartocham
Hi!
Like in a title. I simply want to measure voltage from ADC1 IN5 - PA5.
I want to measure it constantly in my thread. If it hits some value I'll have to set PAD to 1 or 0 but this is not a problem. A problem is that I don't have any measurement results.
I looked into ADC driver note + read examples. I don't have any idea what I'm doing wrong but I constantly get a 0 in my samples.
Can you help me? I think that I'm not understanding correctly configuration structure an here is a problem.
My code:
Code: Select all
/*
ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "ch.h"
#include "hal.h"
#include "halconf.h"
#include "pwm.h"
#include "pal.h"
#include "pwm_lld.h"
#include "pal_lld.h"
#include "hd44780.h"
#include "display.h"
//defines for ADC
//number of channels //
#define ADC_GRP1_NUM_CHANNELS 1
//depth of conversion buffer//
#define ADC_GRP1_BUF_DEPTH 1
// clock variables
uint16_t s1;
uint16_t s2;
uint16_t m1;
uint16_t m2;
uint16_t h1;
uint16_t h2;
// ADC measurement variables
double soil_voltage;
uint16_t voltage_buffer;
uint16_t sample[1] = {0};
// ADC samples buffer.
static adcsample_t samples[ADC_GRP1_NUM_CHANNELS * ADC_GRP1_BUF_DEPTH];
static const ADCConversionGroup adcgrpcfg = {
TRUE,
ADC_GRP1_NUM_CHANNELS,
NULL,
NULL,
/* HW dependent part. */
0, // cr1
ADC_CR2_SWSTART, // cr2
0,
ADC_SMPR1_SMP_AN10(ADC_SAMPLE_41P5),
ADC_SQR1_NUM_CH(ADC_GRP1_NUM_CHANNELS),
0,
ADC_SQR3_SQ2_N(ADC_CHANNEL_IN5)
};
// Voltage measure
static WORKING_AREA(waPomiar, 256);
static msg_t Pomiar(void *arg) {
adcStartConversion(&ADCD1, &adcgrpcfg, samples, ADC_GRP1_BUF_DEPTH);
chThdSleepMilliseconds(2);
voltage_buffer = *samples;
}
/* PWM */
static PWMConfig pwmcfg = {
10000, /* 10Khz PWM clock frequency */
10000, /* PWM period 1 second */
NULL, /* No callback */
/* Only channel 1 enabled */
{
{PWM_OUTPUT_ACTIVE_HIGH | PWM_COMPLEMENTARY_OUTPUT_ACTIVE_HIGH, NULL},
{PWM_OUTPUT_DISABLED, NULL},
{PWM_OUTPUT_DISABLED, NULL},
{PWM_OUTPUT_DISABLED, NULL},
},
0,
0,
#if STM32_PWM_USE_ADVANCED
0
#endif
};
/*
* clock thread
*/
static WORKING_AREA(waThread1, 128);
static msg_t Thread1(void *arg) {
(void)arg;
chRegSetThreadName("clock");
while (TRUE) {
for(h1=0;h1<3;h1++)
{
for(h2=0;h1<5;h2++)
{
for(m1=0;m1<6;m1++)
{
for(m2=0;m2<10;m2++)
{
for(s1=0;s1<6;s1++)
{
for(s2=0;s2<10;s2++)
{
chThdSleepMilliseconds(1000);
}
}
}
}
}
}
}
return 0;
}
int main(void)
{
halInit();
chSysInit();
/* Enables PWM output (of TIM1, channel 1) on LED connected to PA8 */
palSetPadMode(GPIOA, 8, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
/* Enables PWM output (of TIM1, channel 1N) on LED connected to PB13 */
palSetPadMode(GPIOB, 13, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
pwmStart(&PWMD1, &pwmcfg);
pwmEnableChannel(&PWMD1, 0, 5000);
/*
* Initializes the ADC driver 1 and enable the voltage probe
* The pin 5 on the port PA is programmed as analog input.*/
adcStart(&ADCD1, NULL);
/* INTRO */
LCD_Initialize();
disp_intro();
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
while (TRUE) {
Thread *tp = chThdCreateStatic(waPomiar, sizeof(waPomiar), NORMALPRIO, Pomiar, NULL);
chThdWait(tp);
//scale for mV
soil_voltage = ((double)voltage_buffer) *(3000.0/4095.0);
disp_time();
disp_measure();
chThdSleepMilliseconds(1000);
}
}
Thanks for help!
Regards
Matthew
Re: STM32F100 on STM32VL Discovery - Simple ADC voltage meas
Posted: Tue Nov 18, 2014 8:40 am
by Giovanni
Hi,
Two problems:
1) You have to use adcConvert() not adcStartConversion().
2) You must use a non-circular mode so FALSE at beginning of the structure.
3) You are using a wrong macro in structure.
Code: Select all
static const ADCConversionGroup adcgrpcfg1 = {
FALSE,
ADC_GRP1_NUM_CHANNELS,
NULL,
NULL,
0, ADC_CR2_SWSTART, /* CR1, CR2 */
ADC_SMPR1_SMP_AN10(ADC_SAMPLE_1P5),
0, /* SMPR2 */
ADC_SQR1_NUM_CH(ADC_GRP1_NUM_CHANNELS),
0, /* SQR2 */
ADC_SQR3_SQ1_N(ADC_CHANNEL_IN5)
};
Giovanni
Re: STM32F100 on STM32VL Discovery - Simple ADC voltage meas
Posted: Tue Nov 18, 2014 9:30 pm
by bartocham
Hi,
Thanks for help once again.
New version of code:
Code: Select all
/*
ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "ch.h"
#include "hal.h"
#include "halconf.h"
#include "pwm.h"
#include "pal.h"
#include "pwm_lld.h"
#include "pal_lld.h"
#include "hd44780.h"
#include "display.h"
//defines for ADC
//number of channels //
#define ADC_GRP1_NUM_CHANNELS 1
//depth of conversion buffer//
#define ADC_GRP1_BUF_DEPTH 1
// clock variables
uint16_t s1;
uint16_t s2;
uint16_t m1;
uint16_t m2;
uint16_t h1;
uint16_t h2;
// ADC measurement variables
double soil_voltage;
uint16_t voltage_buffer;
uint16_t sample[1] = {0};
// ADC samples buffer.
static adcsample_t samples[ADC_GRP1_NUM_CHANNELS * ADC_GRP1_BUF_DEPTH];
static const ADCConversionGroup adcgrpcfg1 = {
FALSE,
ADC_GRP1_NUM_CHANNELS,
NULL,
NULL,
0, ADC_CR2_SWSTART, /* CR1, CR2 */
ADC_SMPR1_SMP_AN10(ADC_SAMPLE_1P5),
0, /* SMPR2 */
ADC_SQR1_NUM_CH(ADC_GRP1_NUM_CHANNELS),
0, /* SQR2 */
ADC_SQR3_SQ1_N(ADC_CHANNEL_IN5)
};
// Voltage measure
static WORKING_AREA(waPomiar, 256);
static msg_t Pomiar(void *arg) {
adcConvert(&ADCD1, &adcgrpcfg1, samples, ADC_GRP1_BUF_DEPTH);
chThdSleepMilliseconds(2);
voltage_buffer = *samples;
}
/* PWM */
static PWMConfig pwmcfg = {
10000, /* 10Khz PWM clock frequency */
10000, /* PWM period 1 second */
NULL, /* No callback */
/* Only channel 1 enabled */
{
{PWM_OUTPUT_ACTIVE_HIGH | PWM_COMPLEMENTARY_OUTPUT_ACTIVE_HIGH, NULL},
{PWM_OUTPUT_DISABLED, NULL},
{PWM_OUTPUT_DISABLED, NULL},
{PWM_OUTPUT_DISABLED, NULL},
},
0,
0,
#if STM32_PWM_USE_ADVANCED
0
#endif
};
/*
* clock thread
*/
static WORKING_AREA(waThread1, 128);
static msg_t Thread1(void *arg) {
(void)arg;
chRegSetThreadName("clock");
while (TRUE) {
for(h1=0;h1<3;h1++)
{
for(h2=0;h1<5;h2++)
{
for(m1=0;m1<6;m1++)
{
for(m2=0;m2<10;m2++)
{
for(s1=0;s1<6;s1++)
{
for(s2=0;s2<10;s2++)
{
chThdSleepMilliseconds(1000);
}
}
}
}
}
}
}
return 0;
}
int main(void)
{
halInit();
chSysInit();
/* Enables PWM output (of TIM1, channel 1) on LED connected to PA8 */
palSetPadMode(GPIOA, 8, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
/* Enables PWM output (of TIM1, channel 1N) on LED connected to PB13 */
palSetPadMode(GPIOB, 13, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
pwmStart(&PWMD1, &pwmcfg);
pwmEnableChannel(&PWMD1, 0, 5000);
/*
* Initializes the ADC driver 1 and enable the voltage probe
* The pin 5 on the port PA is programmed as analog input.*/
adcStart(&ADCD1, NULL);
/* INTRO */
LCD_Initialize();
disp_intro();
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
while (TRUE) {
chThdCreateStatic(waPomiar, sizeof(waPomiar), NORMALPRIO, Pomiar, NULL);
//scale for mV
soil_voltage = ((double)voltage_buffer) *(3000.0/4095.0);
disp_time();
disp_measure();
chThdSleepMilliseconds(1000);
}
}
I still got warnings that in
Code: Select all
static msg_t Pomiar(void *arg) {
adcConvert(&ADCD1, &adcgrpcfg1, samples, ADC_GRP1_BUF_DEPTH);
chThdSleepMilliseconds(2);
voltage_buffer = *samples;
}
arg is unused and this functions does not have return statement.
Additionally I still got 0 in buffer but after debugging I saw that my program does not enter this thread "Pomiar"
Any ideas?
Re: STM32F100 on STM32VL Discovery - Simple ADC voltage meas
Posted: Tue Nov 18, 2014 9:37 pm
by Giovanni
That thread has the same prioritty of the creating thread so it does not start immediately, it is a thread not a function. You check that value before the thread has been scheduled for execution.
Another point, a thread that calls a function and then terminates is not even useful, why don't you call adcConvert() directly instead of creating that thread?
Keep it simple initially.
Giovanni
Re: STM32F100 on STM32VL Discovery - Simple ADC voltage meas
Posted: Tue Nov 18, 2014 10:04 pm
by bartocham
Yeah, you're right. Sometimes I'm trying to use an atomic bomb against a mosquito

I changed my code again:
Code: Select all
/*
ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "ch.h"
#include "hal.h"
#include "halconf.h"
#include "pwm.h"
#include "pal.h"
#include "pwm_lld.h"
#include "pal_lld.h"
#include "hd44780.h"
#include "display.h"
//defines for ADC
//number of channels //
#define ADC_GRP1_NUM_CHANNELS 1
//depth of conversion buffer//
#define ADC_GRP1_BUF_DEPTH 1
// clock variables
uint16_t s1;
uint16_t s2;
uint16_t m1;
uint16_t m2;
uint16_t h1;
uint16_t h2;
// ADC measurement variables
double soil_voltage;
uint16_t voltage_buffer;
// ADC samples buffer.
static adcsample_t samples[ADC_GRP1_NUM_CHANNELS * ADC_GRP1_BUF_DEPTH];
static const ADCConversionGroup adcgrpcfg1 = {
FALSE,
ADC_GRP1_NUM_CHANNELS,
NULL,
NULL,
0, ADC_CR2_SWSTART, /* CR1, CR2 */
ADC_SMPR1_SMP_AN10(ADC_SAMPLE_1P5),
0, /* SMPR2 */
ADC_SQR1_NUM_CH(ADC_GRP1_NUM_CHANNELS),
0, /* SQR2 */
ADC_SQR3_SQ1_N(ADC_CHANNEL_IN5)
};
/* PWM */
static PWMConfig pwmcfg = {
10000, /* 10Khz PWM clock frequency */
10000, /* PWM period 1 second */
NULL, /* No callback */
/* Only channel 1 enabled */
{
{PWM_OUTPUT_ACTIVE_HIGH | PWM_COMPLEMENTARY_OUTPUT_ACTIVE_HIGH, NULL},
{PWM_OUTPUT_DISABLED, NULL},
{PWM_OUTPUT_DISABLED, NULL},
{PWM_OUTPUT_DISABLED, NULL},
},
0,
0,
#if STM32_PWM_USE_ADVANCED
0
#endif
};
/*
* clock thread
*/
static WORKING_AREA(waThread1, 128);
static msg_t Thread1(void *arg) {
(void)arg;
chRegSetThreadName("clock");
while (TRUE) {
for(h1=0;h1<3;h1++)
{
for(h2=0;h1<5;h2++)
{
for(m1=0;m1<6;m1++)
{
for(m2=0;m2<10;m2++)
{
for(s1=0;s1<6;s1++)
{
for(s2=0;s2<10;s2++)
{
chThdSleepMilliseconds(1000);
}
}
}
}
}
}
}
return 0;
}
int main(void)
{
halInit();
chSysInit();
/* Enables PWM output (of TIM1, channel 1) on LED connected to PA8 */
palSetPadMode(GPIOA, 8, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
/* Enables PWM output (of TIM1, channel 1N) on LED connected to PB13 */
palSetPadMode(GPIOB, 13, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
pwmStart(&PWMD1, &pwmcfg);
pwmEnableChannel(&PWMD1, 0, 5000);
/*
* Initializes the ADC driver 1 and enable the voltage probe
* The pin 5 on the port PA is programmed as analog input.*/
adcStart(&ADCD1, NULL);
/* INTRO */
LCD_Initialize();
disp_intro();
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
while (TRUE) {
// measure Voltage
adcConvert(&ADCD1, &adcgrpcfg1, samples, ADC_GRP1_BUF_DEPTH);
voltage_buffer = *samples;
//scale for mV
soil_voltage = ((double)voltage_buffer) *(3000.0/4095.0);
disp_time();
disp_measure();
chThdSleepMilliseconds(1000);
}
}
But still I see that adcConvert does not return. After I hit a breakpoint set on it I press F6 than nothing. It got stuck. If I break manually I see that program is in IDLE task.

Re: STM32F100 on STM32VL Discovery - Simple ADC voltage meas
Posted: Tue Nov 18, 2014 10:13 pm
by Giovanni
That means that the ADC driver, for some reason, is stuck waiting for the conversion to finish.
Are you using other drivers that may interfere with the ADC DMA channel? that could be the cause. I suggest you enable: assertions, checks and state checker in chconf.h, those option are able to catch many common errors.
Giovanni
Re: STM32F100 on STM32VL Discovery - Simple ADC voltage meas
Posted: Tue Nov 18, 2014 11:02 pm
by bartocham
I don't think so. As a base for this project I was using yours STM32VL discovery demo but I think I have changed conifiguration well.
Here is my MCUconf
Code: Select all
/*
ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#define STM32F100_MCUCONF
/*
* STM32F103 drivers configuration.
* The following settings override the default settings present in
* the various device driver implementation headers.
* Note that the settings for each driver only have effect if the whole
* driver is enabled in halconf.h.
*
* IRQ priorities:
* 15...0 Lowest...Highest.
*
* DMA priorities:
* 0...3 Lowest...Highest.
*/
/*
* HAL driver system settings.
*/
#define STM32_NO_INIT FALSE
#define STM32_HSI_ENABLED TRUE
#define STM32_LSI_ENABLED FALSE
#define STM32_HSE_ENABLED TRUE
#define STM32_LSE_ENABLED FALSE
#define STM32_SW STM32_SW_PLL
#define STM32_PLLSRC STM32_PLLSRC_HSE
#define STM32_PLLXTPRE STM32_PLLXTPRE_DIV1
#define STM32_PLLMUL_VALUE 3
#define STM32_HPRE STM32_HPRE_DIV1
#define STM32_PPRE1 STM32_PPRE1_DIV1
#define STM32_PPRE2 STM32_PPRE2_DIV1
#define STM32_ADCPRE STM32_ADCPRE_DIV2
#define STM32_MCOSEL STM32_MCOSEL_NOCLOCK
#define STM32_RTCSEL STM32_RTCSEL_HSEDIV
#define STM32_PVD_ENABLE FALSE
#define STM32_PLS STM32_PLS_LEV0
/*
* ADC driver system settings.
*/
#define STM32_ADC_USE_ADC1 TRUE
#define STM32_ADC_ADC1_DMA_PRIORITY 2
#define STM32_ADC_ADC1_IRQ_PRIORITY 6
/*
* EXT driver system settings.
*/
#define STM32_EXT_EXTI0_IRQ_PRIORITY 6
#define STM32_EXT_EXTI1_IRQ_PRIORITY 6
#define STM32_EXT_EXTI2_IRQ_PRIORITY 6
#define STM32_EXT_EXTI3_IRQ_PRIORITY 6
#define STM32_EXT_EXTI4_IRQ_PRIORITY 6
#define STM32_EXT_EXTI5_9_IRQ_PRIORITY 6
#define STM32_EXT_EXTI10_15_IRQ_PRIORITY 6
#define STM32_EXT_EXTI16_IRQ_PRIORITY 6
#define STM32_EXT_EXTI17_IRQ_PRIORITY 6
#define STM32_EXT_EXTI18_IRQ_PRIORITY 6
#define STM32_EXT_EXTI19_IRQ_PRIORITY 6
/*
* GPT driver system settings.
*/
#define STM32_GPT_USE_TIM1 FALSE
#define STM32_GPT_USE_TIM2 FALSE
#define STM32_GPT_USE_TIM3 FALSE
#define STM32_GPT_USE_TIM4 FALSE
#define STM32_GPT_USE_TIM5 FALSE
#define STM32_GPT_USE_TIM8 FALSE
#define STM32_GPT_TIM1_IRQ_PRIORITY 7
#define STM32_GPT_TIM2_IRQ_PRIORITY 7
#define STM32_GPT_TIM3_IRQ_PRIORITY 7
#define STM32_GPT_TIM4_IRQ_PRIORITY 7
#define STM32_GPT_TIM5_IRQ_PRIORITY 7
#define STM32_GPT_TIM8_IRQ_PRIORITY 7
/*
* I2C driver system settings.
*/
#define STM32_I2C_USE_I2C1 FALSE
#define STM32_I2C_USE_I2C2 FALSE
#define STM32_I2C_I2C1_IRQ_PRIORITY 5
#define STM32_I2C_I2C2_IRQ_PRIORITY 5
#define STM32_I2C_I2C1_DMA_PRIORITY 3
#define STM32_I2C_I2C2_DMA_PRIORITY 3
#define STM32_I2C_I2C1_DMA_ERROR_HOOK() chSysHalt()
#define STM32_I2C_I2C2_DMA_ERROR_HOOK() chSysHalt()
/*
* ICU driver system settings.
*/
#define STM32_ICU_USE_TIM1 FALSE
#define STM32_ICU_USE_TIM2 FALSE
#define STM32_ICU_USE_TIM3 FALSE
#define STM32_ICU_USE_TIM4 FALSE
#define STM32_ICU_USE_TIM5 FALSE
#define STM32_ICU_USE_TIM8 FALSE
#define STM32_ICU_TIM1_IRQ_PRIORITY 7
#define STM32_ICU_TIM2_IRQ_PRIORITY 7
#define STM32_ICU_TIM3_IRQ_PRIORITY 7
#define STM32_ICU_TIM4_IRQ_PRIORITY 7
#define STM32_ICU_TIM5_IRQ_PRIORITY 7
#define STM32_ICU_TIM8_IRQ_PRIORITY 7
/*
* PWM driver system settings.
*/
#define STM32_PWM_USE_ADVANCED TRUE
#define STM32_PWM_USE_TIM1 TRUE
#define STM32_PWM_USE_TIM2 FALSE
#define STM32_PWM_USE_TIM3 FALSE
#define STM32_PWM_USE_TIM4 FALSE
#define STM32_PWM_USE_TIM5 FALSE
#define STM32_PWM_USE_TIM8 FALSE
#define STM32_PWM_TIM1_IRQ_PRIORITY 7
#define STM32_PWM_TIM2_IRQ_PRIORITY 7
#define STM32_PWM_TIM3_IRQ_PRIORITY 7
#define STM32_PWM_TIM4_IRQ_PRIORITY 7
#define STM32_PWM_TIM5_IRQ_PRIORITY 7
#define STM32_PWM_TIM8_IRQ_PRIORITY 7
/*
* RTC driver system settings.
*/
#define STM32_RTC_IRQ_PRIORITY 15
/*
* SERIAL driver system settings.
*/
#define STM32_SERIAL_USE_USART1 FALSE
#define STM32_SERIAL_USE_USART2 FALSE
#define STM32_SERIAL_USE_USART3 FALSE
#define STM32_SERIAL_USART1_PRIORITY 12
#define STM32_SERIAL_USART2_PRIORITY 12
#define STM32_SERIAL_USART3_PRIORITY 12
/*
* SPI driver system settings.
*/
#define STM32_SPI_USE_SPI1 FALSE
#define STM32_SPI_USE_SPI2 FALSE
#define STM32_SPI_SPI1_DMA_PRIORITY 1
#define STM32_SPI_SPI2_DMA_PRIORITY 1
#define STM32_SPI_SPI1_IRQ_PRIORITY 10
#define STM32_SPI_SPI2_IRQ_PRIORITY 10
#define STM32_SPI_DMA_ERROR_HOOK(spip) chSysHalt()
/*
* UART driver system settings.
*/
#define STM32_UART_USE_USART1 FALSE
#define STM32_UART_USE_USART2 FALSE
#define STM32_UART_USE_USART3 FALSE
#define STM32_UART_USART1_IRQ_PRIORITY 12
#define STM32_UART_USART2_IRQ_PRIORITY 12
#define STM32_UART_USART3_IRQ_PRIORITY 12
#define STM32_UART_USART1_DMA_PRIORITY 0
#define STM32_UART_USART2_DMA_PRIORITY 0
#define STM32_UART_USART3_DMA_PRIORITY 0
#define STM32_UART_DMA_ERROR_HOOK(uartp) chSysHalt()
I'm a newbie so tell me how to check if assertions, checks and state checker are returning some errors during debugging? I simply changed it in chconf.h from false to true, reflashed an run again but nothing happaned.
Re: STM32F100 on STM32VL Discovery - Simple ADC voltage meas
Posted: Wed Nov 19, 2014 9:07 am
by Giovanni
Those debug options halt the system into a loop, then you have to break the application and inspect the stack trace in order to understand which check failed. There is also a pointer dbg_panic_msg that points to an error string in memory.
Giovanni
Re: STM32F100 on STM32VL Discovery - Simple ADC voltage meas
Posted: Wed Nov 19, 2014 9:40 am
by bartocham
Hi,
Ok. After I'll be back at home I'll try.
Do you have any clue after seeing my MCU config why it could fail?
If I understand everything correctly I disabled all interfaces except PWM and ADC.
In my project except of main.c I have only those display functions which are directly connected to HD44780 library. Nothing sofisticated just simple functionality but that ADC fails

Re: STM32F100 on STM32VL Discovery - Simple ADC voltage meas
Posted: Wed Nov 19, 2014 6:46 pm
by bartocham
Hi Giovanni!
I tried to debugg it. What I have seen that I didn't get any panic msg. When program was about to do something like IRQ stack return(after tons of F5 so I didn't notice proper name) it got hit in place presented on below screenshot.
NO mother what I press: return and pause again, F5 or F6 it got stack at this point - at setting thread name.

I've even changed ADC settings in mcuconf.h. Don't know if it is proper but I saw it on other projects.
Now it looks like:
Code: Select all
/*
* ADC driver system settings.
*/
#define STM32_ADC_USE_ADC1 TRUE
#define STM32_ADC_ADC1_DMA_PRIORITY 3
#define STM32_ADC_ADC1_IRQ_PRIORITY 5
#define STM32_ADC_ADC1_DMA_IRQ_PRIORITY 5
I'm bit confused why it is acting like that :/