how do i initialize and use the adc from TM4C123 chip Family

-1

HI i tried to use the ADC0 module of the TM4C123AH6PM chip. but every time i initialize the ADc i get an hard fault error. I think the ADC module is missing the Clock. underneath the source of my initialasation code.

the hard fault occurs every time i tried to read/write to the ADC0 register.

Thanks for your Help

void startup()
{
    SYSCTL->RCC = 0x078E3B80;               //Enable external Clock
    SYSCTL->RCGCGPIO = 0x0000007F;  //Enable GPIO Clock
    SYSCTL->RCGC0 |= 0x00030000;        //activate ADC0
    SYSCTL->RCGC0 &= 0xFFFFFCCF;        //125kHz ADC conversion speed
    //SYSCTL->RCGC2 |=0x0000007F;
    SYSCTL->RCGCADC = 0x00000003;       //Enable ADC Run Mode 0 und 1 
}

void GPIOinit (void)
{
    GPIOE->DIR |= 0x00000000; 
    GPIOE->AFSEL = 0x00000003;
    GPIOE->DR8R = 0x00000000;
    GPIOE->ODR = 0x00000000;
    GPIOE->DEN = 0x00000010;
    GPIOE->AMSEL |= 0x00000003;
}

void ADC_init (void)
{
        ulong test = 0;
    volatile int result;

        GPIOE->AFSEL |=0x08;
        GPIOE->DEN &= ~0x08;
        GPIOE->AMSEL |= 0x08; 
    /* initialize ADC0 */
        ADC0->ACTSS &= ~0x00000008;
        ADC0->EMUX &= ~0xF000;
        ADC0->SSMUX3 = 0;
        ADC0->SSCTL3 |= 0x06;
        ADC0->ACTSS |=0x08;

                ADC0->PSSI |= 0x08;
                while((ADC0->RIS & 0x08 )==0)
                {;}
                result = ADC0->SSFIFO3;
                ADC0->ISC |= 0x08;
}
c
microcontroller
keil
adc
texas-instruments
asked on Stack Overflow Sep 2, 2020 by Unify

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0