[ell-i-developers] Re: PWM working for TIM2

  • From: Ivan Raul <supra.material@xxxxxxxxx>
  • To: ell-i-developers@xxxxxxxxxxxxx
  • Date: Tue, 28 Jan 2014 21:50:03 +0200

Hi to All.

The previous solution generates a warning because a uint16_t pointer is
cast to uint32_t.

I provide a tentative fix to the problem at

https://github.com/supramaterial/Runtime/commit/35c4cbd5707325e433e0cc70b311b7cee561cfe7#diff-cf25b213b312aec6704a44fc5c68c897L87

Although it uses typecast, I am not sure if it is optimal. The problem is
that there is no already made pointer at the stm headers to a uint_32t as
those peripherals are initialized mainly with 16bit registers (in
particular the first one)

Is it possible to use an unnamed union? Although that would create some
extra modification elsewhere.



With Warm Regards, Ivan Raul


On Tue, Jan 28, 2014 at 7:02 PM, Ivan Raul <supra.material@xxxxxxxxx> wrote:

> Dear All.
>
> I have created the pull request for the initial fix to the initialization.
> I have tested the system with those specific changes.
>
> To really make the PWM work, still the GPIO alternate functions need to be
> initialized, do I work on that in parallel with the Serial testing?
>
> With Warm Regards, Ivan Raul
>
>
> On Mon, Jan 27, 2014 at 11:35 PM, Pekka Nikander <pekka.nikander@xxxxxx>wrote:
>
>> >> Nice but far too complicated fix.  The essential things were changing
>> the type of a to a 32-bit pointer instead of being a 16-bit pointer, as you
>> had observed, and fixing the D16 macro to compute the right index.
>> >>
>> >> In your current code you actually store 32 bits for each 16 bits
>> value, and then don't use the upper 16 zeroes at all.
>> >>
>>
>> > I already fixed the space issue, with the size of the uint32_t and the
>> indexes.
>> > From the part that doesn't need typecast you are right, and changing
>> the pointer address is done.
>> >
>> > Now that this is solved, what would be the next step?
>>
>> Please test once more tomorrow the cleaned up code, and create a pull
>> request.
>>
>> After that, you can start testing the Serial code.  You will again learn
>> more, as this time you'll enter to the wonders of C++ and C++11.  I haven't
>> even checked whether the compiler really optimises the const objects away,
>> so more assembler reading.  If there are any non-compile-time C++
>> constructors left, then we need to optimise more the C++ so that the
>> compiler does the right thing and optimises those away.
>>
>> --Pekka
>>
>>
>>
>

Other related posts: