Hi ,
I'm designing an ADC input in K40N256 with TWR-K40X256 board . And I create a project by CW 10.2 Processor Expert .
I create a ADC component and initial it . But how to read the ADC convert result ? Is there any example project for it ?
Channel - AD1DM1
已解决! 转到解答。
Hi,
please find attached a demo project for Kinetis Kwikstik board (using K40).
This demo project is created with use of Processor Expert and it's Peripheral Initialization Components.
Microphone signal is periodically sampled and displayed on the display.
ADC is periodically triggered for 8 kHz (Influenced by Init_PDB period setting).
The ADC (ADC0, channel 10) results are read and automatically stored using DMA into a memory buffer so the CPU is informed after the buffer is full and doesn't have to care for reading each value individually.
best regards
Petr Hradsky
Processor Expert Support Team
Hi,
Could you be more specific what component do you use ? ADC_LDD or Init_ADC ?
Anyway, if you are using ADC_LDD there are generated functions(methods) that you can use. Please see the Typical usage page of the documentation. It's accessible via pop-up menu for the component by selection the command "Help on component" and in the page that opens select the link "Typical Usage".
I you are using Init_ADC, you need to access the ADC registers directly according to the K40X256 manual.
best regards
Petr Hradsky
Processor Expert Support Team
Hi all,
By the way I'm also using the same ADC_LDD but my problem is that I'm doing an audio application and I must set the sampling freq exactly to 16kHz,
I have to set an external counter to set the exactly freq or could it be done using the differrent properties of the component
Br's
Jordi
Hi,
please find attached a demo project for Kinetis Kwikstik board (using K40).
This demo project is created with use of Processor Expert and it's Peripheral Initialization Components.
Microphone signal is periodically sampled and displayed on the display.
ADC is periodically triggered for 8 kHz (Influenced by Init_PDB period setting).
The ADC (ADC0, channel 10) results are read and automatically stored using DMA into a memory buffer so the CPU is informed after the buffer is full and doesn't have to care for reading each value individually.
best regards
Petr Hradsky
Processor Expert Support Team
Surely there is a register to write to trigger a conversion, a bit to poll for end-of-conversion, and a data register to read. Just trying to verify hardware at this stage, need the simplest way to do a conversion.
Erich
Yes I found your blog post, awesome. That is good documentation. It just works. You rock. I tried the other two ADC components (init & LDD), couldn't figure out what to do with them, there seemed to be no API for getting a value. I spent 2 hours on that. Then 10 minutes with your tutorial and had it going.
One point that is not absolutely clear is how to get multiple values. It seems you are meant to pass the address of an array, and the values for each channel are stored sequentially. Kind of a dangerous way of doing things. It would make more sense to pass a channel number.
Hi,
you can also find simple examples of code for using a component on the "Typical usage" page accessible from help of each component. You can get this help using component pop-up menu command "Help on component" and then click the "Typical usage" link in the left side of the help pages.
I'm not sure what do you mean by passing a channel number, but if the component should return the numbers of channels, this would be quite a wasting of memory space, if you application knows the order of channels. RAM is usually quite limited resource in embedded system...
best regards
Petr Hradsky
Processor Expert Support Team
Petr
I am suggesting a better API would have a function something like
word AD1_GetValue16ByChannel(int channel);
which would return the value of the measurement for the particular ADC channel. This function is safe. It's just your basic "getter" function.
Whereas passing a pointer (as in the current implementation) requires that the caller has allocated a buffer of suitable size. If the buffer is too small, you have a problem.
I disagree about saving RAM, I think the current implementation would use more RAM, as the measurements are being buffered both in the driver and in the application code.