You can find in the link below a set of examples that are useful for you. In TIM4 example, you will fin what you are looking for :) http://www.st.com/products/support/micro/files/stm8sfwlib.zip Hope this helps and tell me if It is OK. With regards, MCU Lüfter, be happy be low power
// Configure PF.4 en entrée flotante PRESENCE SECTEUR
GPIOF->CR1&=~0x10;
GPIOF->DDR&=~0x10;
// Configure PB.5 en entrée flotante COURANT BAES
// Configure PB.4 en entrée flotante COURANT BAEH
// Configure PB.3 en entrée flotante TELECOMMANDE
// Configure PB.2 en entrée flotante TENSION Leds Vertes
// Configure PB.1 en entrée flotante Detection presence batterie BAES
// Configure PB.0 en entrée flotante Detection presence batterie BAEH
GPIOB->CR1&=~0x3F;
GPIOB->DDR&=~0x3F;
// Configure PE.5 en sortie PushPull Pilotage Alim driver BAEH
GPIOE->DDR|= 0x20;
GPIOE->CR1|= 0x20;
// Configure PC.4 en sortie PushPull Pilotage Leds Vertes
GPIOC->DDR|= 0x10;
GPIOC->CR1|= 0x10;
// Configure PD.0 en sortie PushPull Pilotage charge batterie BAEH
// Configure PD.2 en sortie PushPull Pilotage charge batterie BAES
// Configure PD.3 en sortie PushPull Pilotage SATI Vert
// Configure PD.4 en sortie PushPull Pilotage SATI Jaune
// Configure PD.7 en sortie PushPull Pilotage Alim driver BAES
GPIOD->DDR|= 0x9D;
GPIOD->CR1|= 0x9D;
while (1) {
if(GTimeStamp <= 200)
{
GPIOD->ODR &= 0x10;
GPIOD->ODR |= 0x10;
}
else
{
GPIOD->ODR &= 0x00;
GPIOD->ODR |= 0x00;
}
while (1);
}
Hi moussa,
You can find in the link below a set of examples that are useful for you. In TIM4 example, you will fin what you are looking for :) http://www.st.com/products/support/micro/files/stm8sfwlib.zip Hope this helps and tell me if It is OK. With regards, MCU Lüfter, be happy be low power
Hello,
I'm using a STM8S105k4 and i need some program to generate an interrupt each 1ms for control of time (for example, create a counter value wich is incremented each interrupt) Thank you for your help,
i added Init_TIM2() to the main() and the interrupt is generated but the flag interrupt is remained in permanant at high level. i dont know
how to pass the flag interrupt to the low state at the end of the increment of the time value.
when run : @far @interrupt void NonHandledInterrupt (void) { /* in order to detect unexpected events during development, it is recommended to set a breakpoint on the following instruction */ return; } Best regards,
Hi Moussa,
Why Init_TIM2
() is not called in main( ) ?
some question regarding WaitDelay
( ) ??? Tell me if it ok or ???? Regards,. MCU Lüfter
Hi,
I tested just now the exemple given in frame library of STM8 and the result is bad (
the time variable is remained the initial value)
. see my code and tell me it's ok or not. thank you so much Regards
// Configure PE.5 en sortie PushPull Pilotage Alim driver BAEH
GPIOE->DDR|= 0x20;
GPIOE->CR1|= 0x20;
// Configure PC.4 en sortie PushPull Pilotage Leds Vertes
GPIOC->DDR|= 0x10;
GPIOC->CR1|= 0x10;
// Configure PD.0 en sortie PushPull Pilotage charge batterie BAEH
// Configure PD.2 en sortie PushPull Pilotage charge batterie BAES
// Configure PD.3 en sortie PushPull Pilotage SATI Vert
// Configure PD.4 en sortie PushPull Pilotage SATI Jaune
// Configure PD.7 en sortie PushPull Pilotage Alim driver BAES
GPIOD->DDR|= 0x9D;
GPIOD->CR1|= 0x9D;
while (1) {
if(GTimeStamp <= 200)
{
GPIOD->ODR &= 0x10;
GPIOD->ODR |= 0x10;
}
else
{
GPIOD->ODR &= 0x00;
GPIOD->ODR |= 0x00;
}
 
while (1);
}
Hi moussa,
You can find in the link below a set of examples that are useful for you. In TIM4 example, you will fin what you are looking for :) http://www.st.com/products/support/micro/files/stm8sfwlib.zip Hope this helps and tell me if It is OK. With regards, MCU Lüfter, be happy be low power
Hello,
I'm using a STM8S105k4 and i need some program to generate an interrupt each 1ms for control of time (for example, create a counter value wich is incremented each interrupt) Thank you for your help,
If the interrupt is generated you should be pointed at the following IRQ: @far @interrupt void TIM2_UPD_OVF_BRK_IRQHandler(void) The TIM2 update flag is cleared by the following function:
TIM2_ClearITPendingBit(TIM2_IT_UPDATE); which write to 0 the ''UIF'' bi in TIM2_SR1 register.
Hope this helps otherwise I need much details. Good luck Moussa ! Regards, MCU Lüfter
to be pointed at the handler (when the interrupt is generated) i must added following code in the main() or not : #ifdef _RAISONANCE_ void TIM2_UPD_OVF_BRK_IRQHandler( void ) #else // COSMIC FAR @interrupt void TIM2_UPD_OVF_BRK_IRQHandler(void) #endif { GTimeStamp++; TIM2_ClearITPendingBit(TIM2_IT_UPDATE); } thank you,
Hi moussa,
If the interrupt is generated you should be pointed at the following IRQ: @far @interrupt void TIM2_UPD_OVF_BRK_IRQHandler(void) The TIM2 update flag is cleared by the following function:
TIM2_ClearITPendingBit(TIM2_IT_UPDATE); which write to 0 the ''UIF'' bi in TIM2_SR1 register.
Hope this helps otherwise I need much details. Good luck Moussa ! Regards, MCU Lüfter
Hi lowpowermcu,
i added Init_TIM2() to the main() and the interrupt is generated but the flag interrupt is remained in permanant at high level. i dont know
how to pass the flag interrupt to the low state at the end of the increment of the time value.
when run : @far @interrupt void NonHandledInterrupt (void) { /* in order to detect unexpected events during development, it is recommended to set a breakpoint on the following instruction */ return; } Best regards,
Hi Moussa,
Why Init_TIM2
() is not called in main( ) ?
some question regarding WaitDelay
( ) ??? Tell me if it ok or ???? Regards,. MCU Lüfter
Hi,
I tested just now the exemple given in frame library of STM8 and the result is bad (
the time variable is remained the initial value)
. see my code and tell me it's ok or not. thank you so much Regards
// Configure PE.5 en sortie PushPull Pilotage Alim driver BAEH
GPIOE->DDR|= 0x20;
GPIOE->CR1|= 0x20;
// Configure PC.4 en sortie PushPull Pilotage Leds Vertes
GPIOC->DDR|= 0x10;
GPIOC->CR1|= 0x10;
// Configure PD.0 en sortie PushPull Pilotage charge batterie BAEH
// Configure PD.2 en sortie PushPull Pilotage charge batterie BAES
// Configure PD.3 en sortie PushPull Pilotage SATI Vert
// Configure PD.4 en sortie PushPull Pilotage SATI Jaune
// Configure PD.7 en sortie PushPull Pilotage Alim driver BAES
GPIOD->DDR|= 0x9D;
GPIOD->CR1|= 0x9D;
while (1) {
if(GTimeStamp <= 200)
{
GPIOD->ODR &= 0x10;
GPIOD->ODR |= 0x10;
}
else
{
GPIOD->ODR &= 0x00;
GPIOD->ODR |= 0x00;
}
 
while (1);
}
Hi moussa,
You can find in the link below a set of examples that are useful for you. In TIM4 example, you will fin what you are looking for :) http://www.st.com/products/support/micro/files/stm8sfwlib.zip Hope this helps and tell me if It is OK. With regards, MCU Lüfter, be happy be low power
Hello,
I'm using a STM8S105k4 and i need some program to generate an interrupt each 1ms for control of time (for example, create a counter value wich is incremented each interrupt) Thank you for your help,
#error clnk Debug\luminaire1025.lkf:73 Debug\stm8_interrupt_vector.o: symbol f_NonHandledInterrupt multiply defined (Debug\stm8s_it.o)
The command: ''clnk -m Debug\luminaire1025.map -l''C:\Program Files\COSMIC\CXSTM8_16K\Lib'' -o Debug\luminaire1025.sm8 Debug\luminaire1025.lkf '' has failed, the returned value is: 1
Probably you have a non-coherence between stm8s_it.c, stm8s.it_h and interrupt_vector.c. Why you are not using the template provided by ST in the standard library. It is easier and faster for start-up ? That was my case when I started enjoying with STM8S micros. Tell me if It is OK now. Regards, MCU Lüfter