TM4C123GH6PM | Potentiometer interfacing with TM4C Launch Pad | Pot interfacing with TM4C Launch Pad

Potentiometer interfacing with TM4C Launch Pad

Program

#include<stdint.h>
#include<stdbool.h>
#include"inc/hw_memmap.h"
#include"driverlib/gpio.h"
#include"driverlib/sysctl.h"
#include"driverlib/adc.h"
// TO STORE THE VALUE IN VARIABLE ui32ADC0Value FOR EVERY SAMPLING
uint32_t ui32ADC0Value[1];
int main(void)
{
SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|
SYSCTL_XTAL_16MHZ); // SYSTEM CLOCK AT 40MHZ
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); // ENABLE ADC0 MODULE
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); // ENABLE GPIO for ADC0 Module
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE,GPIO_PIN_1);
GPIOPinTypeADC(GPIO_PORTE_BASE,GPIO_PIN_3);// ENABLE AN0 OF ADC0 MODULE
// ADC0 MODULE, TRIGGER IS PROCESSOR EVENT, SEQUENCER 0 IS CONFIGURED
ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_PROCESSOR, 0);
// ADC0 MODULE, SEQUENCER 0 , FOR 1 SAMPLING, INPUT IS FROM CHANNEL 0 PE3
ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_CH0);
// ENABLE THE SEQUENCE 1 FOR ADC0
ADCSequenceEnable(ADC0_BASE, 1);
while(1)
{
// TRIGGER IS GIVEN FOR ADC 0 MODULE, SEQUENCER 1
ADCProcessorTrigger(ADC0_BASE, 1);
// STORE THE CONVERTED VALUE FOR ALL DIFFERENT SAMPLING IN ARRAY
//ui32ADC0Value
ADCSequenceDataGet(ADC0_BASE, 1, ui32ADC0Value);
if(ui32ADC0Value[1]>=2048)
    GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1,0x02);
    else
        GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1,0x00);
}
}

Procedure

1. Create a new folder on desktop location as name it as ADC.

2. Open cc studio on desktop.

3. Browse the workspace location

    Click on browseàdesktopàselect created folderàok button.

4. ccstudio wizard is opened

     Click on projectànew ccs projectàtarget [select Tiva c series].

5. Select microcontroller “Tiva TM4C123GH6PM”, click on connection and select “Stellaris in-circuit debug interface”.                                     

6. Name the project in project name bar and click on finish button.

7. Click on restore button on left side and then enter the programà save button.

8. Now unfold the project and right click on project and select properties.

9. Select include optionsàaddàbrowseàmy computeràlocal disc
    c
àtiàTivaware_c_series_2.1.2.111àok. Now directory path is added to project then click on 
    ok button.

10. Select projectà Right click on project à add files à select local disc cà  select tià Tivaware_c_series_2.1.2.111 àselect driverlib à ccs à debug à  driverlib.lib à open button.

11. Select copy files and click ok button. Now driver library file is added to the  project.                                                                                                                                    

12. To build the project click on Build button.

13. CIRCUIT CONNECTION: 10k potentiometer is taken, the middle pin is connected to PE3 in TM4C launch pad, first pin is connected to the 3.3V and the last pin is connected to the GND in TM4C. Connect TM4C launch pad to pc using USB cable.

14. Before debugging set the launch pad in debug mode by pushing wake up pin and click on debug button in ccstudio.

15. Select the potentiometer variable name UI32ADC0 in the program àRight Click on ità

select add watch expression àclick ok buttonàunfold the UI32ADC0 value on expression.

16.  To add the break point select line 32(double click) àRight click on itàbreak point properties àactionàclick on Remain HaultàRefresh all windowsàok.

17.click on Resume button and vary the potentiometer.


Circuit Connection


TM4C123GH6PM Overall Documentation in video description

Video 👇







Comments