hi,
earlier i was working on PIC controller, now i am shifting to ARM and i am having stm32f401re NUCLEO64 evaluation board.
development tool chain i am using is Keil arm mdk , keil version 5. i found some notes for blinking the led on board and i followed the step.
the led is blinking attached on PA5, below is the code,
/* use delay loop, 1 sec on 1 sec off * default 16 MHz clock * LD2 connects to PA5 */ #include "stm32f4xx.h" void delayMs(int n); int main(void) { RCC->AHB1ENR |= 1; /* enable GPIOA clock */ GPIOA->MODER &= ~0x00000C00; /* clear pin mode */ GPIOA->MODER |= 0x00000400; /* set pin to output mode */ while(1) { GPIOA->BSRR = 0x00000020; /* turn on LED */ delayMs(500); GPIOA->BSRR = 0x00200000; /* turn off LED */ delayMs(500); } } /* 16 MHz SYSCLK */ void delayMs(int n) { int i; for (; n > 0; n--) for (i = 0; i < 3195; i++) ; }
now when i want to change the pin PC10 on PORTC. the register i changed is
RCC->AHB1ENR |= 0x04; /* enable GPIOA clock */
GPIOC->MODER |= 0x00200000; /* set pin to output mode */
GPIOC->BSRR = 0x00000400; /* turn on LED */below is the edited code and i am getting nothing. this is the first attempt on stm32 controller. please help me out.
/* use delay loop, 1 sec on 1 sec off * default 16 MHz clock * LD2 connects to PC10 */ #include "stm32f4xx.h" void delayMs(int n); int main(void) { RCC->AHB1ENR |= 0x04; /* enable GPIOA clock */ //GPIOA->MODER &= ~0x00000C00; /* clear pin mode */ GPIOC->MODER |= 0x00200000; /* set pin to output mode */ while(1) { GPIOC->BSRR = 0x00000400; /* turn on LED */ delayMs(500); GPIOC->BSRR = 0x04000000; /* turn off LED */ delayMs(500); } } /* 16 MHz SYSCLK */ void delayMs(int n) { int i; for (; n > 0; n--) for (i = 0; i < 3195; i++) ; }
There is a demonstrating and nice CMSIS-RTOS Blinky example project prepared for the Nucleo-F401RE, offered by the Pack Installer:
http://www2.keil.com/mdk5/packinstaller/
the above first code is running in PA5 pin, then why second code not running on PC10.
i want to get familiar with register, so that i can change, set the bit of register.
if you get any clew in second code reply me and i will try as you mentioned CMSIS _RTOS blinky.
thanking you.
Try single-stepping the code, and reviewing the peripheral register settings via the debugger's view of those.
Review the registers in the context of the F4 Reference Manual description of them.
With software delay loops, use a volatile loop count so it doesn't optimize the code away.