This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

STM32F103VET6 TIM simulation problem

I am starting to develop on STM32F10x. I attempted to use TIM1 to measure PWM input using the following code(copied from a book--prescaler and auto-reload changed to match the signal source):

    /* ... configure PA8 as floating input ... */
    TIM1->CR1   = 0x00000000; //default
    TIM1->CCER  = 0x00000000; //default
    TIM1->PSC   = 0x00000003; //set max prescaler
    TIM1->ARR   = 0x00000009; //set max reload count
    TIM1->CCMR1 = 0x00000001; //Input IC1 mapped to TI1
    TIM1->CCER |= 0x00000000; //IC1 triggers on rising edge
    TIM1->CCMR1|= 0x00000200; //Input IC2 mapped to TI1
    TIM1->CCER |= 0x00000020; //IC2 triggers on falling edge
    TIM1->SMCR  = 0x00000054; //Select TI1FP1 as input,rising edge trigger
    TIM1->CCER |= 0x00000011; //enable capture channels
    TIM1->CR1   = 0x00000001; //enable the timer
    while(1);

After burning and connecting PA8 to the signal source, CCR1 and CCR2 correctly showed the period and duty cycle of the input signal.

I then launched the simulator and ran the same code(both by manually switching the timer pins and setting off a debug function). This time, CCR1 still correctly showed the period, but CCR2 never gets updated.

Since the same code works perfectly on the real chip, I think the STM32F10x simulator is to blame for. Any ideas?

0