Problems with STM32L-Discovery demo
Moderators: RoccoMarco, lbednarz, tfAteba
Problems with STM32L-Discovery demo
I followed the tutorial for using ChibiOS/RT after purchasing a STM32L-Discovery board.
[url]http://www.chibios.org/dokuwiki/doku.php?id=chibios:articles:stm32l_discovery&s[]=stm32[/url]
Everything worked as planned, I downloaded the latest 2.4.0 release, compiled the ARMCM3-STM32L152-DISCOVERY demo using YAGARTO toolchain (also downloaded and installed). All worked fine.
I then downloaded the STLink V2 usb drivers and installed them, downloaded STLink Utility.
As described in the article I removed the LCD screen and went to Maplins and purchased a 3 pin 10k linear pot. Also had a spare RS232 adaptor so connected the pins as described then used a USB to Serial adaptor. Downloaded PuTTY and verified the serial output was working (connecting via 38400 8N1 as described) by re-flashed the board using ChibiOS/RT demo demo. All good so far.
Again as described the demo powered up and the lights started flashing as per what is to be expected. I could see the demo serial output from the self tests when the USER button is pressed.
So far so good. everything seems to be working 'as expected'. Furthermore adjusting the Potentiometer changed the speed of the flashing LED as expected.
Now this is where I hit into some problems...
After a certain 'period' of time which seems to vary the pot simply "stops" working. I left it running for a few mins and the came to adjust the pot and while the green LED is still flashing the POT no longer adjusts the time the green led stays on. Curiously the RTOS doesn't stop working and the tests (from user button) still continue to function... Only the ADC seems to be broken. This is before I've changed a single line of code. Any idea what this could be?
Furthermore I decided to add some debug code into the adccb() function so I could see the values of the pot on the serial console output.
Simply after these lines;
/* Calculates the average values from the ADC samples.*/
avg_ch1 = (samples[0] + samples[2] + samples[4] + samples[6]) / 4;
avg_ch2 = (samples[1] + samples[3] + samples[5] + samples[7]) / 4;
I added;
copy_avg_ch1 = avg_ch1;
copy_avg_ch2 = avg_ch2;
Then in a separate thread I started printing out the values to the serial console..
To accomplish this I first had to init the console output (as i original demo code the console output was only configured in the tests section) so I needed to create a new method to init it *before* any tests where executed.
int initConsoleOutput(void *p)
{
chp = p;
test_println("Console Configured");
}
then just after main() serial init I added it in;
/*
* Activates the serial driver 1 using the driver default configuration.
* PA9 and PA10 are routed to USART1.
*/
sdStart(&SD1, NULL);
palSetPadMode(GPIOA, 9, PAL_MODE_ALTERNATE(7));
palSetPadMode(GPIOA, 10, PAL_MODE_ALTERNATE(7));
/* added init of the console output */
initConsoleOutput(&SD1);
Finally I added a simple hex output function so I could see the result...
/* simple number output routine */
void puthex(unsigned long val)
{
unsigned char buf[10];
int i;
for (i = 7; i >= 0; i--)
{
buf[i] = "0123456789ABCDEF"[val & 0x0F];
val >>= 4;
}
buf[8] = '\0';
test_print(buf);
}
static WORKING_AREA(waThread2, 128);
static msg_t Thread2(void *arg)
{
(void)arg;
chRegSetThreadName("test");
while (TRUE)
{
/* only display updates to console if values have changed... */
if ( (old_avg_ch1 != copy_avg_ch1) || (old_avg_ch2 != copy_avg_ch2) )
{
old_avg_ch1 = copy_avg_ch1;
old_avg_ch2 = copy_avg_ch2;
puthex(old_avg_ch1); test_print(" ");
puthex(old_avg_ch2); test_println(".");
}
chThdSleepMilliseconds(1000);
}
}
Again these seem to work for a while (displaying the temp and pot values) and then after a while 'stop' displaying...
any idea why this happens? Again the self tests continue to work from the button. The RTOS is still running but the ADC conversion doesn't continue....
Any help much appreciated.
[url]http://www.chibios.org/dokuwiki/doku.php?id=chibios:articles:stm32l_discovery&s[]=stm32[/url]
Everything worked as planned, I downloaded the latest 2.4.0 release, compiled the ARMCM3-STM32L152-DISCOVERY demo using YAGARTO toolchain (also downloaded and installed). All worked fine.
I then downloaded the STLink V2 usb drivers and installed them, downloaded STLink Utility.
As described in the article I removed the LCD screen and went to Maplins and purchased a 3 pin 10k linear pot. Also had a spare RS232 adaptor so connected the pins as described then used a USB to Serial adaptor. Downloaded PuTTY and verified the serial output was working (connecting via 38400 8N1 as described) by re-flashed the board using ChibiOS/RT demo demo. All good so far.
Again as described the demo powered up and the lights started flashing as per what is to be expected. I could see the demo serial output from the self tests when the USER button is pressed.
So far so good. everything seems to be working 'as expected'. Furthermore adjusting the Potentiometer changed the speed of the flashing LED as expected.
Now this is where I hit into some problems...
After a certain 'period' of time which seems to vary the pot simply "stops" working. I left it running for a few mins and the came to adjust the pot and while the green LED is still flashing the POT no longer adjusts the time the green led stays on. Curiously the RTOS doesn't stop working and the tests (from user button) still continue to function... Only the ADC seems to be broken. This is before I've changed a single line of code. Any idea what this could be?
Furthermore I decided to add some debug code into the adccb() function so I could see the values of the pot on the serial console output.
Simply after these lines;
/* Calculates the average values from the ADC samples.*/
avg_ch1 = (samples[0] + samples[2] + samples[4] + samples[6]) / 4;
avg_ch2 = (samples[1] + samples[3] + samples[5] + samples[7]) / 4;
I added;
copy_avg_ch1 = avg_ch1;
copy_avg_ch2 = avg_ch2;
Then in a separate thread I started printing out the values to the serial console..
To accomplish this I first had to init the console output (as i original demo code the console output was only configured in the tests section) so I needed to create a new method to init it *before* any tests where executed.
int initConsoleOutput(void *p)
{
chp = p;
test_println("Console Configured");
}
then just after main() serial init I added it in;
/*
* Activates the serial driver 1 using the driver default configuration.
* PA9 and PA10 are routed to USART1.
*/
sdStart(&SD1, NULL);
palSetPadMode(GPIOA, 9, PAL_MODE_ALTERNATE(7));
palSetPadMode(GPIOA, 10, PAL_MODE_ALTERNATE(7));
/* added init of the console output */
initConsoleOutput(&SD1);
Finally I added a simple hex output function so I could see the result...
/* simple number output routine */
void puthex(unsigned long val)
{
unsigned char buf[10];
int i;
for (i = 7; i >= 0; i--)
{
buf[i] = "0123456789ABCDEF"[val & 0x0F];
val >>= 4;
}
buf[8] = '\0';
test_print(buf);
}
static WORKING_AREA(waThread2, 128);
static msg_t Thread2(void *arg)
{
(void)arg;
chRegSetThreadName("test");
while (TRUE)
{
/* only display updates to console if values have changed... */
if ( (old_avg_ch1 != copy_avg_ch1) || (old_avg_ch2 != copy_avg_ch2) )
{
old_avg_ch1 = copy_avg_ch1;
old_avg_ch2 = copy_avg_ch2;
puthex(old_avg_ch1); test_print(" ");
puthex(old_avg_ch2); test_println(".");
}
chThdSleepMilliseconds(1000);
}
}
Again these seem to work for a while (displaying the temp and pot values) and then after a while 'stop' displaying...
any idea why this happens? Again the self tests continue to work from the button. The RTOS is still running but the ADC conversion doesn't continue....
Any help much appreciated.
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: Problems with STM32L-Discovery demo
Hi,
I'll to replicate the problem on my side, is it the latest YAGARTO right?
About the code you added: test_print() is supposed to be used from within the test suite only. You could use chprintf() instead which is a generic formatted output function, it is located under ./os/various, just add it to your makefile.
I suggest to enable the debug options in chconf.h, if the program hangs then inspect the debug variables and the stack trace using the ChibiOS plugin, this could give us an hint of the problem.
Edit: I am running the demo now, is it usually matter of minutes? hours?
Giovanni
I'll to replicate the problem on my side, is it the latest YAGARTO right?
About the code you added: test_print() is supposed to be used from within the test suite only. You could use chprintf() instead which is a generic formatted output function, it is located under ./os/various, just add it to your makefile.
I suggest to enable the debug options in chconf.h, if the program hangs then inspect the debug variables and the stack trace using the ChibiOS plugin, this could give us an hint of the problem.
Edit: I am running the demo now, is it usually matter of minutes? hours?
Giovanni
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: Problems with STM32L-Discovery demo
Another question, you wrote that the green LED goes ON and stops flashing, right? when this happens does the blue LED continue flashing?
Re: Problems with STM32L-Discovery demo
Wow! Thanks for the quick response.
Both lights continue to pulse but the Pot has no effect after some time (which varies). After a reset it works again. Seems as though the callback doesn't happen anymore?? weird.
I'll try to enable the debug and switch to your recommended print functions.
Both lights continue to pulse but the Pot has no effect after some time (which varies). After a reset it works again. Seems as though the callback doesn't happen anymore?? weird.
I'll try to enable the debug and switch to your recommended print functions.
Re: Problems with STM32L-Discovery demo
YAGOTO gcc version is 4.6.2
got from command line...
arm-none-eabi-gcc -dumpversion
got from command line...
arm-none-eabi-gcc -dumpversion
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: Problems with STM32L-Discovery demo
Here it is still running without problems here, weird.
Are you able to monitor the SPI output? if the SPI transmission stops too then it is the ADC callback that is not triggered anymore like you suggested, the SPI transmission is started in the callback. If it isn't the callback then it could be HW related.
We will see with debug options enabled but apparently the application continues working (and thanks for reminding me this, I will increase the default stack values).
Giovanni
Are you able to monitor the SPI output? if the SPI transmission stops too then it is the ADC callback that is not triggered anymore like you suggested, the SPI transmission is started in the callback. If it isn't the callback then it could be HW related.
barthess wrote:Giovanni, it looks like stack overflow in Idle thread.
We will see with debug options enabled but apparently the application continues working (and thanks for reminding me this, I will increase the default stack values).
Giovanni
Re: Problems with STM32L-Discovery demo
Guys,
I may have egg on my face. I'm thinking I may have goofed up on the wiring/soldering (excluse the lame soldering - I'm software guy
.
Has anyone got a picture of the wiring for the POT to the pins on the eval board?
Here's mine... Have I used the WRONG ground ???
I believe I may have...
Would be really valuable to post diagrams illustrating the wiring so its easier to follow for people going through the tutorial!
Can anyone confirm. I also purchased all the other STM eval boards but wanted to start here and then move onto the faster versions.
I may have egg on my face. I'm thinking I may have goofed up on the wiring/soldering (excluse the lame soldering - I'm software guy
Has anyone got a picture of the wiring for the POT to the pins on the eval board?
Here's mine... Have I used the WRONG ground ???
Would be really valuable to post diagrams illustrating the wiring so its easier to follow for people going through the tutorial!
Can anyone confirm. I also purchased all the other STM eval boards but wanted to start here and then move onto the faster versions.
- Attachments
-
- Dsc06527.jpg (89.25 KiB) Viewed 5934 times
-
- to_pot.jpg (72.94 KiB) Viewed 5934 times
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: Problems with STM32L-Discovery demo
Hi,
I will update the guide, good suggestion. This is the picture of my board, sorry for the bad quality but I refuse to get a new phone if the old one is still working...
The ground I used is the one at the lower end of the left connector, the VCC is the third from top. You should not solder on connectors, much better get wirings with female connectors, this way you don't have to solder anything (software guy here too
).
Giovanni
I will update the guide, good suggestion. This is the picture of my board, sorry for the bad quality but I refuse to get a new phone if the old one is still working...
The ground I used is the one at the lower end of the left connector, the VCC is the third from top. You should not solder on connectors, much better get wirings with female connectors, this way you don't have to solder anything (software guy here too
Giovanni
Re: Problems with STM32L-Discovery demo
Thanks Giovanni,
Really appreciate the help. Unfortunately that doesn't seem to have solved my problem either. With the ground changed after about 3 mins of tweaking the settings it 'looses' connection between the pot and the board. I.e. the lights both still continue to flash but at whatever rate it was running at before it 'lost' it. from then on in it does not change the led blink speed - as already mentioned i get no further console output from the thread showing updates (therefore the 'samples[0]' array and avg_ch1 or avg_ch2 is not being updated anymore.
I've re-compiled with debug options turned on but I didn't see any extra console output. How do I see the debug output? Is there a VxWorks style shell I can connect to etc. Any guides you can point me towards or do I just scan the code?
Thanks,
Trevor
Really appreciate the help. Unfortunately that doesn't seem to have solved my problem either. With the ground changed after about 3 mins of tweaking the settings it 'looses' connection between the pot and the board. I.e. the lights both still continue to flash but at whatever rate it was running at before it 'lost' it. from then on in it does not change the led blink speed - as already mentioned i get no further console output from the thread showing updates (therefore the 'samples[0]' array and avg_ch1 or avg_ch2 is not being updated anymore.
I've re-compiled with debug options turned on but I didn't see any extra console output. How do I see the debug output? Is there a VxWorks style shell I can connect to etc. Any guides you can point me towards or do I just scan the code?
Thanks,
Trevor