Does Primer 2 lock TIMER 3 configuration registers?
Hi I am going mad trying to get my Primer2 to output a PWM signal on PB0 (TIM3 Ch3) - which seems otherwise to be unused. The code I use works great on TIM3 channels 1 and 2 on a Primer1, so I thought that the port would be simple.
When running in the debugger, the Timer3 registers are not updated in the init section as per the Primer1, In fact, nearly all peripheral registers show as zero on the primer2.
I must be missing something.
I would appreciate any suggestions
Here is the relevant code called from Application_Ini of a new Primer2 project
thanks in advance
Chris
#include "stm32f10x_lib.h" // need the following define to switch off TYPES declared in circle_api.h // the lib header is in $(RKitLib)/ARM/include #define __STM32F10x_H //#include "stm32f10x.h" //#include "stm32f10x_gpio.h" //#include "stm32f10x_tim.h"
Re: Does Primer 2 lock TIMER 3 configuration registers?
Hi,
It seems that your clock configuration is false : RCC_AHBPeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); RCC_AHBPeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);
Each peripheral clock must be configured depending on the peripheral bus connection (AHB, APB1 or APB2) according to the "Figure 1. STM32F103xC, STM32F103xD and STM32F103xE performance line block diagram" of the STM32F103x datasheet.
Re: Does Primer 2 lock TIMER 3 configuration registers?
Hi Yves, Many thanks for your response, your solution worked 'RIGHT FIRST TIME'. As is so often the case its the basics that cause the most headache when they are incorrect. The brain glosses over them, assuming correctness.
Apologies for not picking up the reply earlier,I have been moving offices.
I am a bit surprised that the compiler did not pick this error up, since the AHB does not have direst acccess to the peripherals concerned. Having a higher level interface for the clocks would add portability to code should a device be defined with different internal bussing.
I guess I've spent too much time in OO wonderland and have not yet grasped all the features and functionality of the Cortex.
As an aside does the bus speed of 4872 /2436MHz refer to an internal serial bus for APB1 and APB2?
Re: Does Primer 2 lock TIMER 3 configuration registers?
Hi Chris,
The compiler cannot detect this error because the syntax is correct from a C point of view, but I agree, the STM32 peripheral clock configuration is not simple ! Peripherals are connected to CPU by three internal parallel bus through bridges. Its max speeds are 72, 48 or 36 MHz depending on the max CPU clock and depending on the bus.
Re: Does Primer 2 lock TIMER 3 configuration registers?
Hi Yves, Thanks. I'll take a look again, I've been using Java for some time, and one would usually have separate enumerations for AHB and APB clock commands.
Re: Does Primer 2 lock TIMER 3 configuration registers?
Hi, I`m new in STM32 Primer2 and trying to disable PWM Pulse after a specific time. I there any simple way to give a delay in application? Is it true that Circle OS doesn`t have delay/wait funcion? I`ve done loop that take the procesor time, but this in not good way, because primer can`t do anything in that time. ... and the second problem is dynamic change value of Width PWM (I haven`t change Period and any other parameters). It is possible to change this value in 'if' loop? (for exemple: if a==0 PWM_Width = 11; if a>0 PWM_Width = 18; if a<0 PWM_Width = 5; )