Rajath Ravi / Mbed 2 deprecated ADC_DMA_POST_LEC12

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "gpio.h"
00002 #include "mbed.h"
00003 #include "hardware_adc.h"
00004 #include "hardware_dma_controller.h"
00005 
00006 Serial pc(USBTX, USBRX);
00007 
00008 
00009 int main(void)
00010 {
00011     uint32_t i,j,k;
00012     j = 0;
00013     
00014     //For Design Problem 1 - Exercise 10 - START
00015     initADC3_5_withDMA();
00016     InitPortBPin0asOutput(); //initialize GPIOB as Output
00017     startADCConversion(); 
00018     //For Design Problem 1 - Exercise 10 - END
00019     
00020     //For Design Problem 2 - Exercise 10 - START
00021     initADC3_567_withDMA();
00022     InitPortBPin0asOutput(); //initialize GPIOB as Output
00023     startADCConversion(); 
00024     //For Design Problem 2 - Exercise 10 - END
00025     
00026     while(1)
00027     {
00028         for (i=0; i<10000000; i++)
00029         {
00030             for(k=0; k<10000000; k++)
00031             {
00032                 j=j+1; //Tiny Delay
00033             }
00034         }
00035         
00036         //Code for DMA - DESIGN PROBLEM 1 - Exercise 10 - START
00037         pc.printf("ADC Value is %u\n", returnADC3StoredValue1Channel(0));
00038         toggleGPIOB0();
00039         //Code for DMA - DESIGN PROBLEM 1 - Exercise 10 - END
00040         
00041         
00042         //Code for DMA - DESIGN PROBLEM 2 - Exercise 10 - START
00043         pc.printf("ADC Value 1 is %u, ADC Value 2 is % u and ADC Value 3 is %u\n", returnADC3StoredValue3Channel(0), returnADC3StoredValue3Channel(1), returnADC3StoredValue3Channel(2));
00044         toggleGPIOB0();
00045         //Code for DMA - DESIGN PROBLEM 2 - Exercise 10 - END
00046     }
00047 }