cancel
Showing results for 
Search instead for 
Did you mean: 

STM8S003f3p6 pin state change problem

Chayan Roy
Associate III
Posted on March 01, 2017 at 07:47

Hello,

   I   am trying  to make  narrow pulse  using timer1 of stm8s003f3p6, without using any kind of pwm(because my application  doesn't permit me to do that). Program is,timer will make PIN 18 of mcu high the a  while loop will start under   the timer interrupt service  routine. (While loop is for creating some micro-seconds delay ,say 100us, untill then the the pin is  high then after 100us pin will be low). Problem is that timer interrupt works fine but PIN  is totally idle, nothing happens. Timer interrupt occurs but there is no change in pin state.  Please tell me if some one has any suggestion. The  code is below:

 #include 'STM8S003F3P.h'

void InitialiseSystemClock(void);

unsigned int i=500;

void main(void){

                   InitialiseSystemClock();

            

                                

                 PD_DDR |=(1<<1);

                 PD_CR1 |=(1<<1);

                 PD_CR2 |=(1<<1);

                                

                              

                                

                                

                                 TIM1_PSCRH=0;

                                 TIM1_PSCRL=16;

                                 TIM1_ARRH=200;

                                 TIM1_ARRL=255;

                                 TIM1_IER=(1<<0);

                                 TIM1_CR1 =(1<<0);

 

                

                  

                 _asm('rim');

                   

                                 while(1){

              

}

}

@far @interrupt void TIMER1_INTERRUPT (void){

PD_ODR |=(1<<1);

while(i !=0){

i--;

}

PD_ODR &=~(1<<1);

TIM1_SR1 =~(1<<0);

}
0 REPLIES 0