Help modify below code using the timer Timer_A to toggle two LEDs in periodic time intervals of A)10 sec B)30 sec C)1 sec
the original code toggled red LED when an overflow occured:
#include <ms430.h>
#define RedLED BIT0
#define RedLEDToggle (P1OUT ^= RedLED)
void main (void)
{
WDTCTL = WDTPW|WDTHOLD;
P1DIR = RedLED;
P1OUT = RedLED;
TECTL = TASSEL_2|ID_3|MC_3|TAIE;
TACCR0 = 62500;
_enable_interrupts();
LPM1; //enter low power mode
}
#pragma vector=TIMER_A1_VECTOR
__interrupt void Timer_A(void)
{
switch(TAIV)
{
case 0x02: break;
case 0x04: break;
case 0x0A; RedLEDToggle;
break;
}
}
Even though the toggle can be done by 'millis' that I have handled previously in many cases. Here I have made some modifications in the code but unable to test the toggle on board but I am sure the code I have given will work. Do make some modifications if required.
#include <ms430.h>
#include <mbed.h>
#define RedLED BIT0
#define RedLEDToggle (P1OUT ^= RedLED)
const unsigned long LED1_interval = 10000;
const unsigned long LED2_interval = 30000;
const unsigned long LED3_interval = 1000;
unsigned long LED1_timer;
unsigned long LED2_timer;
unsigned long LED3_timer;
void main (void)
{
WDTCTL = WDTPW|WDTHOLD;
P1DIR = RedLED;
P1OUT = RedLED;
TECTL = TASSEL_2|ID_3|MC_3|TAIE;
TACCR0 = 62500;
LED1_timer = millis ();
LED2_timer = millis ();
LED3_timer = millis ();
_enable_interrupts();
LPM1; //enter low power mode
}
#pragma vector=TIMER_A1_VECTOR
__interrupt void Timer_A(void)
{
switch(TAIV)
{
case 0x02:
if ( (millis () - LED1_timer) >= LED1_interval)
RedLEDToggle;
break;
case 0x04:
if ( (millis () - LED2_timer) >= LED2_interval)
RedLEDToggle;
break;
case 0x0A;
if ( (millis () - LED3_timer) >= LED3_interval)
RedLEDToggle;
break;
}
}
Help modify below code using the timer Timer_A to toggle two LEDs in periodic time intervals...
C CODE LANGUAGE. MSP430. #include <msp430fr6989.h> #define redLED BIT0 // Red LED at P1.0 #define greenLED BIT7 // Green LED at P9.7 #define BUT1 BIT1 // Button S1 at P1.1 #define BUT2 BIT2 // Button S2 at P1.2 void main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop the Watchdog timer PM5CTL0 &= ~LOCKLPM5; // Enable the GPIO pins // Configure and initialize LEDs P1DIR |= redLED; // Direct pin as output P9DIR |= greenLED; // Direct pin as output...
I need help with doing these tasks for code composer Lab 3 - Branching, Push Button and LEDs-Reading Assignment in this lab, we are going to control a LED via a push button- using general purpose digital 10 for both input (button) and output (LED) on port 1 - using Code Composer Studio. Furthermore, we are going to use a branch instruction to create an IF-ELSE structure in assembly to determine if the LED should be lit up based on...