This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi sir / mam,
I am using TIVA C series launch pad(TM4C123G6PMI). I started to program in that launch pad and finished GPIO's.
I try to communicate ADC through this launch pad. That time controller get more heat. Whenever I connect launch pad to PC and controller get heat.
Thanks and regards,
C.Saravanakumar
hi,
I attached my code. 5V is i connect from external source.
#include<stdint.h>
#include<stdbool.h>
#include<hw_memmap.h>
#include<hw_types.h>
#include<sysctl.h>
#include<hw_sysctl.h>
#include<gpio.h>
#include<hw_gpio.h>
#include<adc.h>
#define RS GPIO_PIN_1
#define RW GPIO_PIN_2
#define EN GPIO_PIN_3
void delay_ms(int del)
{
del=(SysCtlClockGet()/3.0)*del/1000.0;
SysCtlDelay(del);
}
void lcd_cmd(unsigned char a)
{
GPIOPinWrite(GPIO_PORTE_BASE, RS,0); //RS=0
GPIOPinWrite(GPIO_PORTE_BASE, RW,0); //RW=0
GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7, a); //portb=a
GPIOPinWrite(GPIO_PORTE_BASE, EN,8);delay_ms(2);GPIOPinWrite(GPIO_PORTE_BASE, EN,0); //EN=0
}
void lcd_data(unsigned char a)
{
GPIOPinWrite(GPIO_PORTE_BASE, RS,2); //RS=1
GPIOPinWrite(GPIO_PORTE_BASE, RW,0); //RW=0
//EN=1
GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7, a); //portb=a
GPIOPinWrite(GPIO_PORTE_BASE, EN,8);delay_ms(2);GPIOPinWrite(GPIO_PORTE_BASE, EN,0); //EN=0
}
void lcd_init()
{
lcd_cmd(0x38);lcd_cmd(0x0E);lcd_cmd(0x01);
}
void main()
{
uint32_t adcbuffer[1];
SysCtlClockSet(SYSCTL_SYSDIV_5| SYSCTL_USE_PLL| SYSCTL_XTAL_16MHZ| SYSCTL_OSC_MAIN);
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_4);
GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, 0xff);
GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0);
ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH9| ADC_CTL_IE| ADC_CTL_END);
ADCSequenceEnable(ADC0_BASE, 3);
ADCIntClear(ADC0_BASE, 3);
lcd_init(); delay_ms(50);
lcd_cmd(0x80);
lcd_data('R');
while(1)
{
ADCProcessorTrigger(ADC0_BASE, 3); //init trigger
while(!ADCIntStatus(ADC0_BASE, 3, false)); //wait thr till conversion complete
ADCIntClear(ADC0_BASE, 3);
ADCSequenceDataGet(ADC0_BASE, 3, adcbuffer);
unsigned int a=adcbuffer[0];
lcd_cmd(0x80);
//if(a<4096){lcd_data('A');} else lcd_data('B');
if(a>999){lcd_data(48+((a/1000)%10));}
if(a>99){lcd_data(48+((a/100)%10));}
if(a>9){lcd_data(48+((a/10)%10));}
{lcd_data(48+(a%10));}
//GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7, a);
}
}