[ell-i-developers] Re: PWM configuration

  • From: Pekka Nikander <pekka.nikander@xxxxxx>
  • To: ell-i-developers@xxxxxxxxxxxxx
  • Date: Fri, 24 Jan 2014 18:59:20 +0200

Ivan,

I think you are close but not quite right.

Not checking the source, I think this is the original version:

>     const SystemInitRecordData16NoAddress *r
>         = (const SystemInitRecordData16NoAddress 
> *)ra->init_records_data16_no_address;
> 
>     register volatile uint16_t *a = ra->init_record_address16;
>     for (int i = 0; i < ra->init_record_number; i++) {
>         *a = r->init_data16;   // Write 16 bits
>         a += 2;                // Advance by 32 bits
>     }
> }

I think there is here a very simple bug by me, r is not incremented while it 
should be.  Hence, it should be instead as follows:

>         *a = (r++)->init_data16; // Write 16 bits and advance the source
>         a += 2;                  // Advance destination by 32 bits

As far as I can see, that should work.  Please test.

--Pekka


Other related posts: