Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - AlexS

Pages: 1 2 [3] 4
31
NXPTM M522XX, KINETIS and i.MX RT / Re: VBAT Detection
« on: January 14, 2019, 03:57:30 PM »
Hi Mark,

Thanks a lot for your reply! I also tested the code on our custom board and it worked.

This is where I found the original mention about DMA: https://community.nxp.com/thread/466102#comment-1020093

Regards,
Alex

32
NXPTM M522XX, KINETIS and i.MX RT / VBAT Detection
« on: January 04, 2019, 04:40:02 PM »
Hi,

Unfortunately, when we designed our K66-based board, we didn't expect for the MCU designers to not factor in a way of detecting whether VBAT is present or not, without triggering a bus fault when trying to access the RTC registers. Mark, I've seen one of your posts on the NXP technical community mentioning a way to use DMA to detect whether VBAT/RTC are active or not. Do you have some example code on the subject by any chance or maybe suggest an alternative solution?

Thanks,
Alex

33
Hi Mark,

Thanks, the DMX example covers everything I wanted to know. Much appreciated. Will try it today and let you know how it goes.

Regards,
Alex

34
Hi,

So as to not create (yet) another topic, I'll post here. In my PE project that I'm porting, I used one of the FlexTimers to measure the distance between two events. The frequency is configured dynamically on startup, depending on settings, ranging from 2us to 16us / timer tick.  I used the timer period with the 'On Counter Restart' event to detect timeouts.

From my reading of the guide on HW timers (http://www.utasker.com/docs/uTasker/uTaskerHWTimers.PDF), the closest thing available would be the periodic timer using the FlexTimer and then slightly extending its functionality to include the ability to read the counter, change the timer period, reset it and so on.

Also, is it possible to use one of the FTM's channels to essentially have two different periodic interrupts running at the same time on the same module?

35
Thanks, saw the method described in the video before, but as I'm sharing my other code with the Process Expert projects it would've meant to keep two distinct repositories. I've ended up creating versioning my application folder outside of uTasker, with the main PE repository and keep uTasker separate as simply a framework repository.

Alex

36
Hi,

I'm wondering, given that the application code rests in Applications/ and the project configuration file is in the root folder, how should individual application files be versioned when using uTasker?

37
Hi Mark,

Indeed I have. I didn't find sections to cover the ADC calibration routine (how it's performed, not just a mention), nor details on how to run the ADC in free-running mode, without DMA.

Alex

38
Hi,

I've read all of the forum threads on how the ADC operates on the Kinetis and also spent some time trying to understand the examples from ADC_Timers.h. For all the value that uTasker provides, I think a slightly more comprehensive document covering ADC operation and individual examples on various types of setups would greatly improve the experience and alleviate the learning curve. :)

With that in mind, let me jump straight in. Our product requires several ADC channels to be running, sampling and converting at the same time, on both AD0 and AD1. I wrote a simple driver to wrap uTasker's ADC functionality with another layer to provide the same interface as the old Processor Expert drivers. I just want to make sure I got the basics right, if someone more familiar doesn't mind taking a look:

1. First of all, this is the routine for calibrating the ADC. It's only done once for both AD0 and AD1 at startup.

Code: [Select]

adc_setup.int_adc_controller = ad;
adc_setup.int_adc_mode = (ADC_CALIBRATE | ADC_SELECT_INPUTS_A | ADC_CLOCK_BUS_DIV_2 | ADC_CLOCK_DIVIDE_4 | ADC_SAMPLE_ACTIVATE_LONG | ADC_CONFIGURE_ADC | ADC_REFERENCE_VREF | ADC_CONFIGURE_CHANNEL | ADC_SINGLE_ENDED | ADC_SINGLE_SHOT_MODE | ADC_16_BIT_MODE | ADC_SW_TRIGGERED);
adc_setup.int_adc_sample = (ADC_SAMPLE_LONG_PLUS_12 | ADC_SAMPLE_AVERAGING_32); // additional sampling clocks
fnConfigureInterrupt((void *)&adc_setup);

As I'm setting everything up with the interrupts disabled, at this stage I should poll for the result and perform the calibration as described in the Kinetis reference manual? Is there any example on how to do this in uTasker?

2. After performing the ADC calibration, I initialize both AD modules in this manner, for continuous sampling and conversion:

Code: [Select]
adc_setup.int_adc_controller = ad;
adc_setup.int_adc_result = (ad == ADC_MODULE_0) ? (&ad0_results) : (&ad1_results);
adc_setup.int_type = ADC_INTERRUPT;                                  // identifier when configuring
adc_setup.int_adc_bit = chan_msk;
adc_setup.int_adc_mode = (ADC_CONFIGURE_ADC | ADC_CONFIGURE_CHANNEL | ADC_SEQUENTIAL_MODE | ADC_SINGLE_ENDED
| ADC_LOOP_MODE | ADC_ALL_RESULTS  | ADC_START_OPERATION); // single ended configuration in loop mode
adc_setup.int_adc_speed = (ADC_SAMPLING_SPEED(5000000));  // 5MHz sampling (must be between 100kHz and 5MHz)
adc_setup.int_adc_int_type = 0;                                      // no interrupt
fnConfigureInterrupt((void *) &adc_setup);                            // configure and start operation

Then, approximately each 2ms, I read the result values and statuses from the corresponding variables (ad0_results or ad1_results)

Code: [Select]
ADC_RESULTS res;

switch (module) {
case ADC_MODULE_0:
res.ucADC_status = ad0_results.ucADC_status[chan_idx];
res.sADC_value = ad0_results.sADC_value[chan_idx];
break;
case ADC_MODULE_1:
res.ucADC_status = ad1_results.ucADC_status[chan_idx];
res.sADC_value = ad1_results.sADC_value[chan_idx];
break;

Thanks!
Alex

39
Thanks!

Will choose between options #2 and #3. The uParameterSystem looks very tempting. As I said, my stored data is essentially a collection of serialized entities built dynamically at startup, depending on the software version. Given that my data is ~10kBytes in size, if I want to update 100bytes in the middle of the parameter block, would it erase all flash sectors contained in the parameter block or just the one in which the data that I want to edit resides? Worried about flash wear.

40
I can help with the second one. It's in the build folder, next to the AXF/ELF binary file. It has the same root name as the binary, but with '.map' as extension. Open it with any text editor, it contains a lot of useful information on how your RAM and FLASH memory is being spent and is key to understanding what optimizations you need to do.

Alex

41
Hi,

Is manually accessing the FTM_CNT register the only option to get the current value of an FTM counter?

Thanks!

42
NXPTM M522XX, KINETIS and i.MX RT / Re: Undefined reference to _sbrk
« on: June 01, 2018, 01:00:27 PM »
Hi Mark,

Thanks for the reply. As mentioned privately, I've got it running without too much hassle just by defining those variables at the start and end of the heap in the linker file. Plan is that, by the end of this development run, to move the entire project to statically allocated memory anyway.

Alex

43
Hi,

As I have mentioned before, I'm currently working on porting a project based on Processor Expert and Code Warrior, running on a K22 to uTasker. In the PE project, the storage solution chosen was based on a basic storage system written from scratch that ran on top of PE's drivers for the MCU's internal flash. It worked (and still does) great. Before I ask my question, I'll briefly describe the storage mechanism:

1. Data that I need to store is essentially a collection of entities, serialized at different sizes, each uniquely identified through an ID.
2. On device power-up, the storage routines would try and load a basic storage system control structure from a predefined address in flash. That control structure would contain a set of entries, each offering a data entity id, offset in flash  and size of the stored data.
3. For each of the data entities, it would go at the specified offset, load the specified entity, check its integrity and deserialize it.
4. During the normal operation of the device, those entities might be modified externally, operation which would trigger the storage system to erase and then update that entity's flash serialized version.

My first instinct was to use the low-level flash routines. One downside is that I'll need to add a driver on top of that to backup the other data in the sector(s) to be erased. Not a big problem, but that got me thinking if it wouldn't be better to use the built-in file system for added functionality down the line.

Thoughts?

Alex

44
NXPTM M522XX, KINETIS and i.MX RT / Undefined reference to _sbrk
« on: May 30, 2018, 12:13:03 PM »
Hi,

Been working to port the original project (based on Processor Expert and CodeWarrior) to uTasker and MCUXpresso. Things are going quite smoothly, support is great, but, as some parts of my code use dynamic memory allocation, ran into an 'undefined reference _sbrk' linker error. Did some digging and found the reason to be the lack of libcr_c.a and libcr_eabihelpers.a, which, as far as I can work out, are archives with Redlib implementations for these functions.

The new linker error is an undefined reference to _pvHeapStart which I can easily sort by defining those symbols in the linker file, but it somehow doesn't feel right.

Thanks!


45
NXPTM M522XX, KINETIS and i.MX RT / Re: UART DMA Defines
« on: May 24, 2018, 05:31:08 PM »
Thanks, Mark! It's working fine now.

Pages: 1 2 [3] 4