Problems with STM32L-Discovery demo
Posted: Sun Mar 04, 2012 12:11 pm
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.