cancel
Showing results for 
Search instead for 
Did you mean: 

Generic F103 board & the proverbial Blink

ea6987
Associate II
Posted on June 16, 2016 at 05:55

Howdy all!

So i have purchased a generic ebay f103 with the yellow headers, you know the one. I have worked with Atmel Arm based chips before, no ASF just register access. I cannot seem to get the LED on PC13 to blink, i can get it on but it stays on and ignores values set on ODR and BRR in other words it does NOT go off once on, in fact it tunrs on by simply setting the OUTPUT PUSH PULL bits withouth me every setting output high on ODR or BSRR Furthermore i have tried STD_PERIPH implemintation and those dont even turn the led on. I have tried CUBEMX's verbose version of the code and that does not even turn it on, atleast with my code it goes on just not off On a side note, i have an f303 discovery board jumping through hoops but this f103 sucker is not cooperating

#include ''stm32f10x.h''
int main ()
{
SystemInit();
//below code turns the led on without me setting output high on the odr or bssr
RCC->APB2ENR |= 1<<
4
; 
GPIOC->CRH |= 00<<
22
;
GPIOC->CRH |= 10<<
20
;
//Has not effect LED stays on
GPIOC->BSRR = 1<<
29
;
GPIOC->BRR = 1<<
13
; 
GPIOC->ODR &=~(1<<13);
}

2 REPLIES 2
Posted on June 16, 2016 at 06:45

> f103 with the yellow headers, you know the one.

No.

> I have worked with Atmel Arm based chips before, no ASF just register access.

I wonder how exactly did you do that, given the errors you made.

GPIOC->CRH |= 00<<
22
;

This does nothing. Zero shifted to left is zero and ORing zero to anything does not change things. Note, that content of CRH register is NOT zero after reset.

GPIOC->CRH |= 10<<
20
;

The ''10'' given in RM is binary, i.e. 2 decimal. gcc allows the 0b10 notation, I don't know about other compilers. Embedded programs should end with an endless loop. The startup code might have saved the day, or not. JW
ea6987
Associate II
Posted on June 17, 2016 at 06:19 Thanks for the reply, the code has been fixed per your comment but still the LED stays on, even though i have NOT set the output high. and does not turn off with writes to ODR or BSRR

int main ()
{
SystemInit();
RCC->APB2ENR |= (1<<
4)
; 
GPIOC->CRH &= ~(1<<
22
);
GPIOC->CRH &= ~(1<<
23
);
GPIOC->CRH |= (1<<
21
);
GPIOC->CRH &= ~(1<<
20
);
//Neither Has an effect, LED stays on
GPIOC->BSRR = (1<<
29)
;
GPIOC->ODR &= ~(1<<13);
while(1)
{
}
}

EDIT: The logic on that LED from hell is inverted !!! That explains a lot!! I have not yet soldered anything but i hope the rest of the pins are not like so