[ell-i-developers] Re: PWM configuration

  • From: Ivan Raul <supra.material@xxxxxxxxx>
  • To: ell-i-developers@xxxxxxxxxxxxx
  • Date: Fri, 24 Jan 2014 14:43:16 +0200

Great, I have been checking the old runtime, but didn't checked that
initialization code. I'll continue accordingly.

With Warm Regards, Ivan Raul


On Fri, Jan 24, 2014 at 2:38 PM, Pekka Nikander <pekka.nikander@xxxxxx>wrote:

> Hi Ivan,
>
> It may also be a good idea to have a look at the old runtime and the
> corresponding code there:
>
>
> https://github.com/Ell-i/Arduino/blob/ell-i/hardware/ell-i/stm32/variants/ellduino_stm32f051/stm32f051_init.c
>
> It is known to work there.  Hence, everything that are direct copies are
> unlike to have bugs.  The bugs are more likely to be either in the changed
> surrounding initialisation code, which was completely rewritten, or in the
> pin definitions.
>
> It may also be a good idea to start with a simpler timer, like TIM3 or
> TIM15.
>
> --Pekka
>
> On 2014-01-24, at 14:33 , Ivan Raul <supra.material@xxxxxxxxx> wrote:
>
> > Dear all.
> >
> > I've been working with the testing of the PWM at the new runtime
> (ell-i-new branch).
> >
> > After solving the addressing problem of:
> >
> > @ellduino_timer.c
> >
> > # define D16(p, r, v) [offsetof(p, r)/2] = { v }
> >
> > and reordering the declarations of the initialisation records:
> >
> > @arduelli_timer.h
> >
> > for obtaining the adequate order at the .hex file (shown by the nm
> command)
> >
> > @sketch.lst
> >
> > 080003dc <TIM2_RCC_INIT>:
> > 080003ec <TIM2_INIT1>:
> > 080003fc <TIM2_INIT>:
> >
> > the pwm still doesn't work.
> >
> > In particular, I'm playing with the B3 pin (pin 13 in arduino), that
> directly connects with the TIM2 Channel 2.
> >
> > I've tried to initialize the timer manually, accessing the registers
> directly.
> >
> > Some highlights are that the TIM2 doesn't have a BDTR register, that the
> initialization procedure tries to write. In the datasheet, it is regarded
> as reserved. That register has the offset 0x44, and is mainly used for
> advanced timers, like TIM1.
> >
> > Another interesting point is that TIM2 in particular is able to count in
> 32 bits. For that reason, the CNT, ARR, and  CCRx registers are 32 bits.
> Regarding that, it is true that after the initialization with 16bits
> initialization routines, the ARR register does not have the desired value,
> as the MSB are loaded with garbage.
> >
> > For the reasons before, I tried to configure it by accessing the
> registers directly. I had have no success. Another interesting fact is that
> in the datasheet (reference manual) of the MCU (page 370), it is specified
> that for PWM mode an update should be generated to update the real
> registers (ARR), because it is double buffered.
> >
> > The update is generated by writing the EGR register:
> >
> >     TIM2->EGR |= TIM_EGR_UG;
> >
> > Still, the system doesn't activate the timer. The counter stays at 0 all
> the time.
> >
> > I will continue by isolating the code to try to activate the timer by
> hand, and then port that configuration to the initialization records.
> >
> >
> > With Warm Regards, Ivan Raul
>
>
>

Other related posts: