Hi
I'm a beginner and as a beginner, I start with simple code....
#include "stm32f4xx.h" // Device header void delayMs(int delay); int main(void) { RCC->AHB1ENR |=1; //ENABLE GPIOA clock GPIOA->MODER |= 0x00000400; // ob 0000 0000 0000 0000 0000 0100 0000 0000 while(1) { GPIOA->ODR = 0x00000020; delayMs(500); GPIOA->ODR &=~0x20; delayMs(500); } } void delayMs(int delay) { int i=0; for(;delay>0;){ delay --; for (i=0;3195;i++); } }
Kiel does not like tilde at the line GPIOA->ODR &=~0x20;
with the warning: main.c(15): warning: implicit conversion changes signedness: 'int' to 'unsigned int' [-Wsign-conversion].
Without that line, I could switch on the LED connected, but once I add this line, the LED is always on.
Any idea?
Thanks in advance
Fausto Tromba
not specific to Keil - this is a 'C' language thing.
By default, literal numeric constants are of type int.
You can use the 'u' suffix to specify a literal constant as unsigned; eg,
GPIOA->ODR &=~0x20u;
en.cppreference.com/.../integer_literal