Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main_Lec9.cpp
00001 #include "gpio.h" 00002 #include "led1.h" 00003 #include "main_Lec9.h" //Mort: including main_Lec9.h 00004 #include "mbed.h" 00005 #include "hardware_timer3.h" 00006 #include "interrupt.h" 00007 00008 Serial pc(USBTX, USBRX); 00009 00010 00011 int main(void) 00012 { 00013 uint32_t i,j; 00014 //uint16_t countervalue; 00015 //uint16_t checkvalue; 00016 00017 /* All of your init functions need to be here */ 00018 00019 //This is for first LED function 00020 //init_LED1(); //Calling the initialization function - To initialize PortB as its corresponding functionality //Mort: Do not need to say void here 00021 00022 //This is for Probelm 10 Exercises - START 00023 // //This is for Output Compare: 00024 // InitGPIOBPin0asOutputCompare(); 00025 // TMR3CH3OutputCompare(); 00026 // 00027 // //This is for Input Capture: 00028 // InitGPIOCPin6asInputCapture(); 00029 // TMR3CH1GPIOCPin6asInputCapture(); 00030 //This is for Probelm 10 Exercises - END 00031 00032 00033 // //Exercise 11 PWM MODE - 1st Problem - START 00034 // //Initializing PortB Pin 0 as a Output Pin 00035 // InitGPIOBPin0asPWMMode1(); 00036 // TMR3CH3OutputPWMMode1(); 00037 // //Exercise 11 PWM MODE - 1st Problem - END 00038 00039 // //Exercise 11 PWM MODE - 2nd Problem - START 00040 // //Initializing PortB Pin 0 as a Output Pin 00041 // InitPortBPin0asOutput(); 00042 // initTimer3ToInterrupt(); 00043 // //Exercise 11 PWM MODE - 2nd Problem - END 00044 00045 //Exercise 11 PWM MODE - 3rd Problem - START 00046 //Initializing PortB Pin 0 as a Output Pin 00047 enableEXTI6OnPortC(); 00048 //Exercise 11 PWM MODE - 3rd Problem - END 00049 00050 00051 while(true) 00052 { 00053 //Create FOR Loop to have some delay between toggling 00054 for(i=1; i<100; i++) //Mort: Your code was fine, just your delay was too large. 00055 { 00056 //pc.printf("hi hi hi \n"); 00057 j=j+1; 00058 } 00059 toggle_LED1(); //Function Call to toggle LED 00060 00061 // countervalue = readCounterValueIfFlagIsSet(); 00062 // if (countervalue > 0 & checkvalue != countervalue) 00063 // { 00064 // pc.printf("\nCounter Value is = %d", countervalue); 00065 // checkvalue = countervalue; 00066 } 00067 } 00068 } 00069 00070 void debugPrint(uint32_t what) 00071 { 00072 pc.printf("The value is %u\n",what); 00073 } 00074
Generated on Sat Oct 21 2023 04:38:55 by
1.7.2