I am programming the STM8L051F3 processor for a simple application in which it is only necessary to control all GPIO.
The problem is that I can't control the GPIOC pin 0.
I just configured the GPIO registers. Is any other startup necessary?
I also tried to use stm8cubemx on Ubuntu. Software that I found useless because it generates an ioc8 file that has no information on how to use it in Ubuntu.
#include <stdint.h>
#include <string.h>
#include "stm8l.h"
void config_gpio(){
//76543210
PA_DDR = 0b00000000;
PA_CR1 = 0xff;
PA_CR2 = 0x00;
//76543210
PB_DDR = 0b00100110;
PB_CR1 = 0xff;
PB_CR2 = 0x00;
//76543210
PC_DDR = 0b01110011;
PC_CR1 = 0xff;
PC_CR2 = 0x00;
//76543210
PD_DDR = 0b00000000;
PD_CR1 = 0xff;
PD_CR2 = 0x00;
PA_ODR = 0x00;
PB_ODR = 0x00;
PC_ODR = 0x00;
PD_ODR = 0x00;
return;
}
void delay(unsigned long delay){
unsigned long i = 0;
for(i = 0; i < delay; i++) {}
return;
}
void rotate_left(int steps){
int n=0;
for(n=0; n<steps; n++){
//PC_DDR = 0b01110011;
//76543210
PC_ODR = 0b01100001;
delay(100);
PC_ODR = 0b00110001;
delay(100);
PC_ODR = 0b00010011;
delay(100);
PC_ODR = 0b01000011;
delay(100);
}
return;
}
void rotate_right(int steps){
int n=0;
for(n=0; n<steps; n++){
//PC_DDR = 0b01110011;
//76543210
PC_ODR = 0b01000011;
delay(100);
PC_ODR = 0b00010011;
delay(100);
PC_ODR = 0b00110001;
delay(100);
PC_ODR = 0b01100001;
delay(100);
}
return;
}
int main() {
config_gpio();
do {
delay(7777);
rotate_right(100);
rotate_left(100);
} while(1);
}
Terminal cmd.
Compile sdcc -lstm8 -mstm8 --opt-code-size --std-sdcc99 --nogcse --all-callee-saves --debug --verbose --stack-auto --fverbose-asm --float-reent --no-peep -I./ -I./STM8S_StdPeriph_Driver/inc -D STM8L051 ./main.c
Prog stm8flash -c stlinkv2 -p stm8l051f3 -s flash -w main.ihx