Re:ADC sequencer-3 not working properly
hi Jeni, im new with this kind of C programming. Im currently working with the sample sequencer 3, I just want to display the on-chip temperature on the OLED, but something its wrong, the value is getting null, I mean, I dunno why the "temperature" is 0 in my case. Could you help me a bit ? here is my code:
#include "hw_types.h" #include "debug.h" #include "sysctl.h" #include "diag.h" #include "../displays/rit128x96x4.h"
#include "hw_memmap.h" #include "hw_ints.h" #include "adc.h" #include "ustdlib.h" #include <stdio.h> #include "string.h" #include "math.h"
// The error routine that is called if the driver library encounters an error. #ifdef DEBUG void __error__(char *pcFilename, unsigned long ulLine) { } #endif
int main(void) { unsigned long temp; unsigned long temp2; SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); // Activar el clock del ADC SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC); ADCHardwareOversampleConfigure(ADC_BASE,64);// // Configure sample sequence 3: processor trigger, priority = 0 ADCSequenceConfigure(ADC_BASE, 3, ADC_TRIGGER_PROCESSOR, 0); // Configure sample sequence 3 step 0 ADCSequenceStepConfigure(ADC_BASE, 3, 0, ADC_CTL_TS | ADC_CTL_END); //Activa el sequencer 3 ADCSequenceEnable(ADC_BASE,3); //Activa la interrupcion ADCIntEnable(ADC_BASE, 3); IntEnable(INT_ADC3); // Configurar el ADC para muestrear 500KSps //SysCtlADCSpeedSet(SYSCTL_ADCSPEED_500KSPS); //SysCtlADCSpeedSet(SYSCTL_ADCSPEED_1MSPS); // Desabilitar el sample sequencer 3 //ADCSequenceDisable(ADC_BASE, 3);
// Obtiene los datos del sample sequencer 3 de la FIFO temp2 = ADCSequenceDataGet(ADC_BASE, 3, &temp); char szBuffer [32]; unsigned long temporal1 = temp2; int i; for(i = 0; i < 10; i++){ szBuffer[i] = (temporal1%10) +0x30; temporal1 = temporal1/10; } RIT128x96x4Init(1000000); RIT128x96x4StringDraw(&szBuffer, 0, 24, 15); DiagExit(0); }
Could you help me please ? =(,
Thanks in advance
login or register to reply
|