STM32L_Discovery Blinking LEDS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-08-21 12:12 AM
I have an STM32L-Discovery Board, I found this program compiled it and loaded it on my board but nothing happens. What am I miising.. Thanks in Advanced.
CM.GPIO_InitTypeDef (GPIO_InitStructure); int main() { GPIO_InitTypeDef ledInit; long i = 0; // enable the GPIOB peripheralRCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; // push-pull output GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz; GPIO_Init (GPIOB, & GPIO_InitStructure); // B port GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7; //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; // push-pull output GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz; GPIO_Init (GPIOB, & GPIO_InitStructure); // B port // configure pins 6 and 7 as GPIO output ledInit.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_6; ledInit.GPIO_Mode = GPIO_Mode_OUT; // initialize the peripheral GPIO_Init(GPIOB, &ledInit); // turn pins 6 and 7 on GPIO_SetBits(GPIOB, GPIO_Pin_7 | GPIO_Pin_6); // loop forever for (;;) { // toggle pins 6 and 7 GPIOB->BSRRL = GPIO_Pin_7; GPIOB->BSRRH = GPIO_Pin_7; GPIOB->BSRRL = GPIO_Pin_6; GPIOB->BSRRH = GPIO_Pin_6; // waste time for (i=0; i<25000; i++); return 0; }- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-08-21 12:30 AM
In fact, the LED blink, but you can't see it.
ThisGPIOB->BSRRL = GPIO_Pin_7; GPIOB->BSRRH = GPIO_Pin_7; sets then resets PB.7 in rapid succession, producing a very short pulse on it. The same in the following two lines for PB.6. You won't see the LED to blink for a fraction of microsecond. (Also, get rid of the second initialization of the GPIO) JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-08-21 8:04 AM
Hi, Jan is right.
Try this: GPIOB->BSRRL = GPIO_Pin_7; for (i=0; i<25000; i++); GPIOB->BSRRH = GPIO_Pin_7;GPIOB->BSRRL = GPIO_Pin_6; for (i=0; i<25000; i++); GPIOB->BSRRH = GPIO_Pin_6;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-08-21 10:44 AM
You guys Rock :)... This works for the STM32L-Discovery Boards compiled with Keil..
Not sure why this isn't in the SDK Project files... Again many thanks for you quick response.Chuck- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-08-21 2:51 PM
I'd recommend looking at both the L1 Discovery examples, and those in the L1 Firmware Library. While the latter is targeting the EVAL series boards, it is still useful.
See also \Keil\ARM\Boards\ST\STM32L-Discovery\Blinky\Blinky.c and examples posted to the forum.Up vote any posts that you find helpful, it shows what's working..
