The more elegant version is: void SystemInitData16NoAddress(const SystemInitRecordArray *ra) { 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++; r++; } } With Warm Regards, Ivan Raul On Fri, Jan 24, 2014 at 6:53 PM, Ivan Raul <supra.material@xxxxxxxxx> wrote: > I changed to a more elegant version... still no difference. I'm thinking > if there is no problem that the routine writes to reserved values. In order > to keep the original intended functionality of the routine, I propose this > alternative. > > To write in the offset of the 16bit register(also applies to 32b) to the > struct > > @system_init.h > > From this: > > typedef struct { > const uint16_t init_data16; > } SystemInitRecordData16NoAddress; > > To something like this > > typedef struct { > const uint16_t init_data16; > const uint16_t offset; > } SystemInitRecordData16NoAddress; > > Then it would be possible to only write the addresses we want in a compact > fashion, and would avoid extra space in storage, as right now if we write > two registers e.g. one at offset 0x00 and other at offset 0x44 (as now does > timer init), it generates in total a 35 elements array (considering 16b > elements), instead of two. > > Thank you for your comments. > > > With Warm Regards, Ivan Raul > > > On Fri, Jan 24, 2014 at 6:22 PM, Ivan Raul <supra.material@xxxxxxxxx>wrote: > >> Some advice... >> >> I have two problems. The first is that this function seems to not advance >> the *r pointer. >> I am not sure if my solution is correct. >> >> Second, it needs to advance only by 16 bits, as the size of the array, is >> the size of the total 16 elements, not only the ones we need to write. For >> that reason, I modified the initialization procedure of the timer to >> include all non - reserved registers, to put them to their reset state, as >> this function will write all the values as size of the array. This function >> so far is only able to update the first element, but fails for the rest. >> >> void SystemInitData16NoAddress(const SystemInitRecordArray *ra) { >> 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[i])->init_data16; // Write 16 bits >> // a += 2; // Advance by 32 bits >> a++; >> >> } >> } >> >> >> With Warm Regards, Ivan Raul >> >> >> On Fri, Jan 24, 2014 at 5:07 PM, Ivan Raul <supra.material@xxxxxxxxx>wrote: >> >>> I made the pull request, has the previous changes. I hope to have >>> something solid to push later today. >>> >>> With Warm Regards, Ivan Raul >>> >>> >>> On Fri, Jan 24, 2014 at 4:43 PM, Pekka Nikander >>> <pekka.nikander@xxxxxx>wrote: >>> >>>> >>>> > Pekka: What do you suggest as following step? I was planning first to >>>> make the timer configured from initialization records, and then start >>>> porting the AF default values to the gpio initialization. >>>> >>>> Sounds good to me. Also start committing your fixes so that I'll be >>>> able to merge them. >>>> >>> >>> >> >