Hi,
So I not long ago recieved my tiva c launchpad. So anyway completing the workshops and lab 1-4 work perfectly. Lab 5 also seems ok. Now I connect an lm35 to the input ain0 input pin. Set it up. For some weird reason the first time through debug mode it pauses on the line while(!ROM_ADCIntStatus(ADC0_BASE, 1, false)) -- commented in code below.. When I wait a moment and then click the resume it all works perfectly..
This would make me think it's a timing thing anyone else have any ideas?
Code below:
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/debug.h"
#include "driverlib/gpio.h"
#include "driverlib/sysctl.h"
#include "driverlib/adc.h"
#define TARGET_IS_BLIZZARD_RB1
#include "driverlib/rom.h"
#ifdef DEBUG
void__error__(char *pcFilename, uint32_t ui32Line)
{
}
#endif
int main(void)
{
uint32_t ui32ADC0Value[4];
volatile uint32_t ui32TempAvg;
volatile uint32_t ui32TempValueC;
volatile uint32_t ui32TempValueF;
ROM_SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
ROM_ADCHardwareOversampleConfigure(ADC0_BASE, 64);
ROM_GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3);
ROM_ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_PROCESSOR, 0);
ROM_ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_CH0);
ROM_ADCSequenceStepConfigure(ADC0_BASE, 1, 1, ADC_CTL_CH0);
ROM_ADCSequenceStepConfigure(ADC0_BASE, 1, 2, ADC_CTL_CH0);
ROM_ADCSequenceStepConfigure(ADC0_BASE,1,3,ADC_CTL_CH0|ADC_CTL_IE|ADC_CTL_END);
ROM_ADCSequenceEnable(ADC0_BASE, 1);
while(1)
{
ROM_ADCIntClear(ADC0_BASE, 1);
ROM_ADCProcessorTrigger(ADC0_BASE, 1);
while(!ROM_ADCIntStatus(ADC0_BASE, 1, false))
{
}
ROM_ADCSequenceDataGet(ADC0_BASE, 1, ui32ADC0Value);
ui32TempAvg = (ui32ADC0Value[0] + ui32ADC0Value[1] + ui32ADC0Value[2] + ui32ADC0Value[3] + 2)/4;
ui32TempValueC = (1475 - ((2475 * ui32TempAvg)) / 4096)/10;
ui32TempValueF = ((ui32TempValueC * 9) + 160) / 5;
}
}
Warwick