TIM1 PWM (Problem) in atolic don't work but in IAR workbench it work

Share code examples or discuss embedded software, including device drivers, interrupt handlers, middleware and application code.

Moderators: Markus Girdland, Mattias Norlander

qwerasd1234
Posts: 1
Joined: Tue Dec 05, 2017 10:49 pm

TIM1 PWM (Problem) in atolic don't work but in IAR workbench it work

Postby qwerasd1234 » Tue Dec 05, 2017 11:03 pm

Hi,

I have a problem with Atollic truestudio for ARM.
I created new project, all things I Customized to my work.
I write code in IAR Embedded Workbench - code worked - generate pwm signal on Tim1 ch1, but in Atollic this code nothing do.
Where can I find something setting, which will be responsible for this error ??
I add that systick and debug work correctly. Also CPU freq is correctly
Debuger is ST-LINK, via SWD.

Thanks for your attention.

Code: Select all

#include "stm32f103xb.h"
#include "gpio.h"  // my gpio lib
#include "gpio.c"
volatile int zmienna=0;
int i;
int main(void){

   RCC->APB2ENR= RCC_APB2ENR_IOPCEN|RCC_APB2ENR_IOPAEN | RCC_APB2ENR_AFIOEN | RCC_APB2ENR_TIM1EN;

   gpio_pin_cfg(GPIOC, 13, GPIO_CRx_MODE_CNF_OUT_PP_2M_value);
   gpio_pin_cfg(GPIOA, 8, GPIO_CRx_MODE_CNF_ALT_PP_2M_value);  //PWM SILNIK

    SysTick_Config(3600000 * 1);

    TIM1->CCMR1 = TIM_CCMR1_OC1M_2|TIM_CCMR1_OC1M_1|TIM_CCMR1_OC1PE;
    TIM1->CCER = TIM_CCER_CC1E;

    TIM1->PSC = 72;
    TIM1->ARR = 100;
    TIM1->CCR1 = 10;
    TIM1->EGR= TIM_EGR_UG;
    TIM1->CR2 = TIM_CR2_OIS1;
    TIM1->BDTR = TIM_BDTR_MOE;
    TIM1->CR1 = TIM_CR1_ARPE|TIM_CR1_CEN;

while(1){
i++;
} /* while(1) */

} /* main */
void SysTick_Handler(void){
zmienna++;
   if (zmienna==10)
   {zmienna=0;
  GPIOC->ODR^= P13;
        }
}

frank_ee
Posts: 65
Joined: Wed Apr 05, 2017 5:08 pm
Location: USA

Re: TIM1 PWM (Problem) in atolic don't work but in IAR workbench it work

Postby frank_ee » Thu Dec 21, 2017 7:58 pm

Hello,

Try using the STM CubeMX tool to generate the PWM code. Did you intialize the GPIO module?

DD4DA
Posts: 40
Joined: Thu Jan 11, 2018 10:06 pm

Re: TIM1 PWM (Problem) in atolic don't work but in IAR workbench it work

Postby DD4DA » Sun Mar 18, 2018 10:35 am

The code snipped is not enought to analyse the problem.
- Clock of GPIO?
- alternate functions clocked and re-routed?
- data direction of gpio right?
- init the gpio?

That's all questions that i mention about, that i can't check by the snipped you posted.


Return to “Embedded target code development discussions”

Who is online

Users browsing this forum: No registered users and 1 guest