AnsweredAssumed Answered

Yet another blink a led question

Question asked by qwer.asdf on Mar 12, 2017
Latest reply on Mar 15, 2017 by qwer.asdf

I'm sorry in advance for such a stupid question, yet i can't find my error.

I have some chinese nameless "stm32f103c8t6 system board" with F103C8T6 on board. I also use Coocoox IDE and ST-Link v2 programmer. The following code should blink a led, which is pulled up through 1k resistor. Also pin A1 is giving me only ~1.830 Volts when set to HIGH; however, when i set A1 to LOW it still shows ~1.830 Volts. Other pins are showing zero results. Did i get shady MC or am i missing something?

Also, i don't have oscilloscope, so i can't check what is going on with MCO pin, yet i get ~20-30 mVolts, which is not above ground level.

 

void InitGPIO()
{
   RCC-> APB2ENR |= RCC_APB2ENR_AFIOEN;
   RCC-> APB2ENR |= RCC_APB2ENR_IOPAEN;

   GPIOA-> CRL &= ~GPIO_CRL_MODE1; // push-pull output
   GPIOA-> CRL &= ~GPIO_CRL_CNF1; // led init on pin a1
   GPIOA-> CRL |= GPIO_CRL_MODE1_1; // 2mhz output
   GPIOA-> BSRR |= GPIO_BSRR_BR1; // rst a1 led pin

   GPIOA-> CRL &= ~GPIO_CRL_MODE2; // push-pull output
   GPIOA-> CRL &= ~GPIO_CRL_CNF2; // pin a2
   GPIOA-> CRL |= GPIO_CRL_MODE2_0; // 10mhz output
   GPIOA-> BSRR |= GPIO_BSRR_BS2; // set a2 pin

   

   GPIOA-> CRH &= ~GPIO_CRH_MODE8;
   GPIOA-> CRH &= ~GPIO_CRH_CNF8;
   GPIOA-> CRH |= GPIO_CRH_CNF8_1; // af push pull output
   GPIOA-> CRH |= (GPIO_CRH_MODE8_1
                           | GPIO_CRH_MODE8_0); // 50mhz output

   // RCC-> CFGR |= RCC_CFGR_MCO_HSE; // hse clk on mco pin
   // RCC-> CFGR |= RCC_CFGR_MCO_PLL; // pll clk on mco pin
   RCC-> CFGR |= RCC_CFGR_MCO_SYSCLK;// sysclk on mco pin
}

 

int main(void)
{
   InitGPIO();;
while(1)
{

return 1;
}

Outcomes