/* * lab2_base.c * * Created on: Dec 5, 2017 * Author: johnsontimoj */ /////////////////////////////////////////// // // This codes flashes an external LED on and off // and prints on or off to the console // // The external LED is connected to P4.0 // which is bit 0 on PORT 4 // // Inputs: none // Outputs: external LED // ///////////////////////////////////////////// // includes #include "msp.h" // includes all the MSP details #include // includes our print and scan functions void main(void){ setbuf(stdout, NULL); // Code Composer Bug Fix // Set the direction for Port 4, bit 0 to OUTPUT // this requires Port4 direction register bit 0 to be a 1 // Want P4 Direction register to be abcd efg1 // So we would take the current value abcd efgh // and OR it with 0000 0001 // This would require: P4->DIR = P4->DIR | 0x01; // but we can use the shorthand version: P4->DIR |= 0x01; P4->DIR |= 0x01; printf("Lab2 base\n"); // print out lab ID and a new line while(1){ // create an infinite loop // Set the value for Port 4, bit 0 to 1 to turn on the LED // this requires Port4 output register bit 0 to be a 1 P4->OUT |= 0x01; printf("ON\n"); // Delay for 1 sec (3M clocks given a 3MHz clock frequency - default for msp432) __delay_cycles(3000000); // Set the value for Port 4, bit 0 to 0 to turn off the LED // this requires Port4 output register bit 0 to be a 0 P4->OUT &= ~0x01; printf("OFF\n"); // Delay for 1 sec __delay_cycles(3000000); } // end while return; } // end main