Tuesday, 10 April 2018
Monday, 9 April 2018
Wednesday, 4 April 2018
Tiva sample program
https://drive.google.com/file/d/1gU5ltJz2vNjiXVYCLcwu1Wz5n60eISWz/view?usp=drivesdk
Tiva sensor output
https://drive.google.com/file/d/1IN_IGvXjYqetBKpodUaYlhWx80jZ-QnT/view?usp=drivesdk
Tiva sensor
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/debug.h"
#include "driverlib/sysctl.h"
#include "driverlib/adc.h"
int main(void)
{
uint32_t ui32ADC0Value[4];//We will be using sequencer 1 which has a FIFO depth of 4
volatile uint32_t ui32TempAvg;//variable is for storing the average of the
temperature
volatile uint32_t ui32TempValueC; //temperature values for Celsius
volatile uint32_t ui32TempValueF; //temperature values for Fahrenheit
//Set up the system clock again to run at 40MHz
SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);
//Let’s enable the ADC0 peripheral
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
//For this lab, we’ll simply allow the ADC12 to run at its default rate of 1Msps.
//Reprogramming the sampling rate is left as an exercise for the student
// Configure the ADC to sample at 500KSps
//SysCtlADCSpeedSet(SYSCTL_SET0_ADCSPEED_500KSPS);
//ADC0, sample sequencer 1, we want the processor to trigger the sequence and we
//want to use the highest priority
ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_PROCESSOR, 0);
//Configure steps 0 - 2 on sequencer 1 to sample the temperature sensor
(ADC_CTL_TS)
ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_TS);
ADCSequenceStepConfigure(ADC0_BASE, 1, 1, ADC_CTL_TS);
ADCSequenceStepConfigure(ADC0_BASE, 1, 2, ADC_CTL_TS);
//The final sequencer step requires a couple of extra settings.
//Sample the temperature sensor (ADC_CTL_TS) and configure the interrupt flag
//(ADC_CTL_IE) to be set
//when the sample is done. Tell the ADC logic that this is the last conversion on
//sequencer 1 (ADC_CTL_END).
ADCSequenceStepConfigure(ADC0_BASE,1,3,ADC_CTL_TS|ADC_CTL_IE|ADC_CTL_END);
//enable ADC sequencer 1
ADCSequenceEnable(ADC0_BASE, 1);
while(1)
{
ADCIntClear(ADC0_BASE, 1);
//trigger the ADC conversion with software
ADCProcessorTrigger(ADC0_BASE, 1);
//wait for the conversion to complete
while(!ADCIntStatus(ADC0_BASE, 1, false))
{
}
//When code execution exits the loop in the previous step, we know that the
//conversion is
//complete and that we can read the ADC value from the ADC Sample Sequencer 1
FIFO.
ADCSequenceDataGet(ADC0_BASE, 1, ui32ADC0Value);
ui32TempAvg = (ui32ADC0Value[0] + ui32ADC0Value[1] + ui32ADC0Value[2] +
ui32ADC0Value[3] + 2)/4;
//In datasheet refer page no. 813
ui32TempValueC = (1475 - ((2475 * ui32TempAvg)) / 4096)/10;
ui32TempValueF = ((ui32TempValueC * 9) + 160) / 5;
}
}
Tiva ADC
// HEADER FILES
#include<stdint.h>
#include<stdbool.h>
#include"inc/hw_memmap.h"
#include"driverlib/gpio.h"
#include"inc/hw_types.h"
#include"driverlib/debug.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
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)
{
// CLEAR INTERRUPT FLAG FOR ADC0, SEQUENCER 1
ADCIntClear(ADC0_BASE, 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);
}
}
PIC Course with IIT Bombay
Embedded Lab Course with PIC18F4550 by IIT Bombay 2017-18 Overview: Below course was conducted as an outreach initiative of Wadhwani Elect...

-
The APB divider determines the relationship between the processor clock (CCLK) and the clock used by peripheral devices (PCLK). The APB di...
-
VLSI Design & Technology Pune University study material Design and Implementation of 4 bit ALU using VHDL DOWNLOAD Desi...
-
#include<LPC214x.h> #define CS1 1<<13 //p0.13 #define CS2 1<<14 //p0.14 #define RS 1<<25 #d...