Part Number: EK-TM4C1294XL
Hello Team,
I've been trying to use the ADC on a Tiva RM4C1294 but everytime I try to measure AN0, the USTAT bits are set after enabling Sample Sequencer 3. I used this basic demo and commented out SystemInit from system_TM4C129.c; when debugging, the execution is stucked in "while((ADC0->RIS & 8) == 0) ;" :
#include <TM4C129.h>
int main(void)
{
unsigned int adc_value;
/* Enable Clock to ADC0 and GPIO pins*/
SYSCTL->RCGCGPIO |= (1<<4); /* Enable Clock to GPIOE or PE3/AN0 */
SYSCTL->RCGCADC |= (1<<0); /* AD0 clock enable*/
/* initialize PE3 for AIN0 input */
GPIOE_AHB->AFSEL |= (1<<3); /* enable alternate function */
GPIOE_AHB->DEN &= ~(1<<3); /* disable digital function */
GPIOE_AHB->AMSEL |= (1<<3); /* enable analog function */
/* initialize sample sequencer3 */
ADC0->ACTSS &= ~(1<<3); /* disable SS3 during configuration */
ADC0->EMUX &= ~0xF000; /* software trigger conversion */
ADC0->SSMUX3 = 0; /* get input from channel 0 */
ADC0->SSCTL3 |= (1<<1)|(1<<2); /* take one sample at a time, set flag at 1st sample */
ADC0->ACTSS |= (1<<3); /* enable ADC0 sequencer 3 */
SYSCTL->RCGCGPIO |= 0x20; // turn on bus clock for GPIOF
GPIOF_AHB->DIR |= 0x08; // set GREEN pin as a digital output pin
GPIOF_AHB->DEN |= 0x08; // Enable PF3 pin as a digital pin
while(1)
{
ADC0->PSSI |= (1<<3); /* Enable SS3 conversion or start sampling data from AN0 */
while((ADC0->RIS & 8) == 0) ; /* Wait untill sample conversion completed*/
adc_value = ADC0->SSFIFO3; /* read adc coversion result from SS3 FIFO*/
ADC0->ISC = 8; /* clear coversion clear flag bit*/
/*control Green PF3->LED */
if(adc_value >= 2048)
GPIOF_AHB->DATA = 0x08; /* turn on green LED*/
else if(adc_value < 2048)
GPIOF_AHB->DATA = 0x00; /* turn off green LED*/
}
}
void SystemInit(void)
{
SCB->CPACR |= 0x00f00000;
}
Regards,
Renan