thannara123
Advanced Member level 5
I am new ,in STM32 . I have an old board STM32 value discovery (STM32f100RBT6B)
I wrote a code for LED blinking But not working ,whats the wrong
I wrote a code for LED blinking But not working ,whats the wrong
C:
LED PC8 & PC9 trying to Blink
i am not well in shift operator programming
#include <stdint.h>
#define RCC_CFGR_BASE_ADDR 0x40021000UL
#define RCC_CFGR_REG_OFFSET 0x04UL
#define RCC_CFGR_REG_ADDR (RCC_CFGR_BASE_ADDR + RCC_CFGR_REG_OFFSET )
#define RCC_APB2ENR_REG_OFFSET 0x18UL
#define RCC_APB2ENR_REG_ADDR (RCC_CFGR_BASE_ADDR + RCC_APB2ENR_REG_OFFSET )
#define GPIO_MODE_BASE_ADDR 0x40011000UL
#define GPIO_MODE_REG_OFFSET 0x04UL
#define GPIO_MODE_REG_ADDR (GPIO_MODE_BASE_ADDR + GPIO_MODE_REG_OFFSET )
#define GPIO_MODE_ODR_OFFSET 0x0CUL
#define GPIO_MODE_ODR_ADDR (GPIO_MODE_BASE_ADDR + GPIO_MODE_ODR_OFFSET )
int main(void)
{
uint32_t *pRccCfrReg = (uint32_t*)RCC_CFGR_REG_ADDR;
uint32_t *pRccApb2EnReg = (uint32_t*)RCC_APB2ENR_REG_ADDR ;
uint32_t *pGPIOModeReg = (uint32_t*)GPIO_MODE_REG_ADDR;
uint32_t *pGPIO_OdrReg = (uint32_t*)GPIO_MODE_ODR_ADDR;
*pRccCfrReg |= (0x5 << 24); // Selected HSI as clock bit position 24(1),25(0),26(1)
*pRccApb2EnReg |= (0x2 << 3);// Pheriperal clock enable
*pGPIOModeReg |= (0x22);// // Output mode, max speed 2 MHz. & 00: General purpose output push-pull
while(1)
{
*pGPIO_OdrReg = (0xfffff);
for(volatile uint32_t i =0; i<1000; i++)
;
*pGPIO_OdrReg = (0x0);
}
}
Last edited: