To whom it may concern,
I am looking for some C code to read 6 channels of ADC on the ADuC7024 (ADC0 through ADC5). Need to read each at 100Hz sample rate.
one way is to program Timer1 for a 100Hz periodic IRQ and take the 6 samples in the Timer 1 Interrupt Handler.I have attached such a simple project for Keil µVision4.Here I used a different setting for the ADC clock to improve the acquisition (16 clocks), but also to increase the sampling speed. I have seen with this settings better results than with the default from datasheet.Additional improvements are possible.
If you replace the "for"-loop with sequential statements, you can reduce the approx. 11µs it takes to do the
6 samples and to store the ADC results.
I loaded up your project. I assume this is using the Real-view compiler? When I build the project, I get these errors:
ADuC7024_ADC0_to_ADC5.axf: Error: L6200E: Symbol IRQ multiply defined (by adc0_to_adc5.o and irq_arm.o).ADuC7024_ADC0_to_ADC5.axf: Error: L6200E: Symbol SWI multiply defined (by adc0_to_adc5.o and irq_arm.o).ADuC7024_ADC0_to_ADC5.axf: Error: L6200E: Symbol FIQ multiply defined (by adc0_to_adc5.o and irq_arm.o).ADuC7024_ADC0_to_ADC5.axf: Error: L6200E: Symbol UNDEF multiply defined (by adc0_to_adc5.o and irq_arm.o).ADuC7024_ADC0_to_ADC5.axf: Error: L6200E: Symbol PABORT multiply defined (by adc0_to_adc5.o and irq_arm.o).ADuC7024_ADC0_to_ADC5.axf: Error: L6200E: Symbol DABORT multiply defined (by adc0_to_adc5.o and irq_arm.o).
I have seen these before when porting something from the GNU compiler to the Real-view compiler. Usually it has something to do with the startup file.
What do you recommend?
this mainly is related to the tool installation and the used Compiler files for C-startup and
what include-files you use.
I have used the latest version of µVision4 (MDK4.12) downloaded from the Keil WebSite.
Also I used in that toolset the RealView C-Compiler.
Possibly you check out the mentioned files for a difference to the latest installed files.
You can use for reinstallation the backup-option to do that.
can you provide detailed schematics (PDF-File) & layout (Gerber or PDF).
Most of the cases I've seen are layout related.
In the attached code, the ADC is oversampled. I am using your settings for a Heart Rate Monitor application. I am sampling at 100Hz per your settings. However, maybe my board has a poor layout because there appears to be spikes at 8.9 kHz (looking on a scope) that are riding on top of the 100Hz signal. Do you think this could be happening due to the settings here:
ADCCP = 0; // select ADC Channel ADCCON = 0x03E3; // start ADC // fADC/1=> sampling @ 1.193Msps (0.838µs) // 16 * fADC aquisition // Enable start // Enable ADCBusy output // Enable ADC power // Single-Ended Mode // Single-SW-Conversion ADCCON = 0x0363; // Disble ADC restart -> see datasheet while(ADCSTA != 0x01); // wait for ADC to convert // store ADC Reseult sensorState.sensorData[(sensorState.sensorDataIndex * SENSORDATASIZE)+5] = ADCDAT >> 16;
I do repeat this code 6 times with ADCCP = 0 through 5.
Any idea as to why I might have a 8.9 KHz spike in my signal??