2010-09-27 04:02 AM
timer interruptions on STM8L152C6
2011-05-17 06:10 AM
The problem I am having is when running the program TIM4_CNTR, the timer counter doesnot increment.
Does anybody know what are the settings that should be applied to overcome this issue? Also when TIM4 register values are set using the following syntax they do not get assigned. TIM4_CR1 = 0x01; // Start the timer Any body having idea on how t do that? Thank you.2011-05-17 06:10 AM
Hi ANN,
Perhaps you should enable the TIM4 clock through clock register. You should use something like this: CLK_PeripheralClockConfig(CLK_Peripheral_TIM4, Enable); You can find a set of examples in the package provided by ST. I am finding useful as start point ''STM8l15x_StdPeriph_Lib'' http://www.st.com/mcu/familiesdocs-120.html good luck. Regards, MCU Lüfter2011-05-17 06:10 AM
Hi again,
In my understang of STM8L15x devices, to use timer with interrupt you should perform the following steps: 1- Enable peripheral (USART, SPI, Timer...) clock using clock registers PCKENR 2- Configure the timer and enable update (overflow) interrupt 3- enable global interrupt (enableInterrupts() <----> rim: reset interrupt mask) 4- enable timer counter: the counter starts counting at this moment 5- in timer IRQ, update flag should be cleared I think that this is what you have to do. If there is some missed step thanks to remember me. good luck. MCU Lüfter2011-05-17 06:10 AM
Hello Lowpowermcu,
Enable system clock on timer using clock registers PCKENR solved out all my troubles. thanks a lot. I did 1,2 and 4 from ur list. Am not aware of 3 and 5 of your list. Especially IRQ update flag, i could not find it. Any way thanks for the help provided. :D2011-05-17 06:10 AM
2011-05-17 06:10 AM
Hello,
In order to achieve USART transmission functionality it is asked to ''Write the data to send in the USART_DR register'' in the STM8L15x microcontroller family reference manual. Eventhough i have used the following form,USART1_DR =0x41; // ASCII 41 = A In the debugging mode what i have noted is that, data is not written into USART1_DR. Also I have performed the following settings as well.CLK_PCKENR1 = 0x20; //Enable SYSTEM clk to USART1 MAP_CR1 = 0x00; //USART!CK remap on PC4; USART1_TX on PC3 and USART1_RX on PC2 USART1_CR1 = 0x10; //Enable USART; 8 bit data USART1_CR3 = 0x08; //1 STOP bit; USART_CK enabled; //fSYSTEM = 16MHz; baud rate = 9600bps; USART_DIV = 1667 = 0683h USART1_BRR2 = 0x03; USART1_BRR1 = 0x68; USART1_CR2 = 0xCA; //txd enable; txd interrupt enabled Can some body tell me are there any more register configurations to be done? Thank you.2011-05-17 06:10 AM
Hello,
In order to achieve USART transmission functionality it is asked to ''Write the data to send in the USART_DR register'' in the STM8L15x microcontroller family reference manual. Eventhough i have used the following form,USART1_DR =0x41; // ASCII 41 = A In the debugging mode what i have noted is that, data is not written into USART1_DR. Also I have performed the following settings as well.CLK_PCKENR1 = 0x20; //Enable SYSTEM clk to USART1 MAP_CR1 = 0x00; //USART!CK remap on PC4; USART1_TX on PC3 and USART1_RX on PC2 USART1_CR1 = 0x10; //Enable USART; 8 bit data USART1_CR3 = 0x08; //1 STOP bit; USART_CK enabled; //fSYSTEM = 16MHz; baud rate = 9600bps; USART_DIV = 1667 = 0683h USART1_BRR2 = 0x03; USART1_BRR1 = 0x68; USART1_CR2 = 0xCA; //txd enable; txd interrupt enabled Can some body tell me are there any more register configurations to be done? Thank you.