2015-05-27 05:04 AM
hello again, how to do bit handling in STVD for STM8s for ex i want to set PA1 = 0 or CEN = 1, enable timer1. i dont see any header file supporting the same. please give me some examples.
thank you #bit-handling #stm8 #stvd2015-05-30 02:29 PM
I think I understand your request.
You need to add some standard modules that are included in the STM8S library.To set/clear bits like PA1 you need to add stm8s_gpio.c to your project, then use one of the built in functions such as,GPIO_WriteHigh(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef PortPins) andGPIO_WriteLow(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef PortPins) to set high and low.Example: GPIO_WriteHigh(GPIOA, GPIO_PIN_1); // sets port A bit 1 highFor timers you will need to add stm8s_timX.c to your project (Where X=1,2,3 or 4 to indicate which timer you are using).Example:// setup and start timer 3, used as a free running timerTIM3_DeInit(); // reset timer 3TIM3_TimeBaseInit(TimerPrescale, 0xffff); // prescaler 0x7fff, time period 0xffffTIM3_Cmd(ENABLE); // enable timer 3For other functions like interrupt control registers you can write directly to an address (look up the address and bit values in the reference manual, I use RM0016).Example:EXTI->CR1 = 0x08; // set port B interrupts to falling edge onlyHope this helps.Rick