STM8S Timer1 input capture issue

Status
Not open for further replies.

radioratiometrics

New Member
Hello am working with the timer1 input capture of an STM8S103F3. No input is registered by the input capture module though I fed it with square waves from 10Hz all the way up to 1MHz. The same square wave registers properly in the input capture module of a pic micro. I have seen that the PC6 (TIM1 Channnel1) pin is set to TIM1 channel1 as an alternate function but I have not found anything helpful in the STM8S standard development library. I have pasted my code below in case anyone can help thanks:


#include "stm8s.h"



void main()
{
CLK_DeInit();
CLK_HSICmd(ENABLE);
CLK_LSICmd(DISABLE);
CLK_HSECmd(DISABLE);
CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1);
CLK_SYSCLKConfig(CLK_PRESCALER_CPUDIV1);


GPIO_Init(GPIOC, GPIO_PIN_4, GPIO_MODE_IN_FL_NO_IT);
CLK_CCOConfig(CLK_OUTPUT_CPUDIV32);
CLK_CCOCmd(ENABLE);



GPIO_Init(GPIOC,GPIO_PIN_6,GPIO_MODE_IN_PU_NO_IT);

TIM1_DeInit();
CLK_PeripheralClockConfig(CLK_PERIPHERAL_TIMER1 , ENABLE);

TIM1_ICInit( TIM1_CHANNEL_1, TIM1_ICPOLARITY_RISING,TIM1_ICSELECTION_DIRECTTI,TIM1_ICPSC_DIV1, 0x00);
TIM1_SelectInputTrigger(TIM1_TS_TI1FP1);
TIM1_SelectSlaveMode(TIM1_SLAVEMODE_RESET);

TIM1_ITConfig(TIM1_IT_CC1,ENABLE);
TIM1_GenerateEvent(TIM1_EVENTSOURCE_CC1);
TIM1_ClearFlag(TIM1_FLAG_CC1);
TIM1_UpdateRequestConfig(TIM1_UPDATESOURCE_REGULAR);
TIM1_Cmd(ENABLE);


enableInterrupts();


while (1);


}


/***********Contents of stm8s_it.c*********************/

uint16_t Capture;
uint8_t Buf[10];

INTERRUPT_HANDLER(TIM1_CAP_COM_IRQHandler, 12)
{
if(TIM1_GetITStatus(TIM1_IT_CC1)==SET)
{
Capture=TIM1_GetCapture1();
TIM1_ClearFlag(TIM1_IT_CC1);
}
}
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…