2016-06-15 08:55 PM
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);
}
2016-06-15 09:45 PM
> 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
2016-06-16 09:19 PM
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