This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi,
Im trying to count time on an artificial RTC (Im using a MSP430G2553 which doesnt have an inbuilt one) and simultaneously blink an LED at 5 second intervals.
Eventually I want to count the number of pulses I get in a square wave and store it with a timestamp from this RTC and thought the LED step would at least show me if my RTC is working.
I'm very VERY new to this (first ever embedded C) and I'm struggling with it a lot. This code is the product of days worth of researching and its still not working.
#include <msp430g2553.h>
#include "RTC.h"
volatile unsigned
int RTC_Counter = 0; // TIMERA0
interrupt service routine
#pragma vector=TIMERA0_VECTOR __
interrupt void Timer_A (void)
{
incrementSeconds();
RTC_Counter ++;
if(RTC_Counter > 5)
{
P1OUT = 0b00000001;
RTC_Counter = 0;
}
else {
LPM3_EXIT;
}
}
void init()
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
setTime(0x12, 0 , 0, 0); //intialise to 12:00:00AM
CCR0 = 32768 - 1;
P1DIR |= 0x00; //P1.0 output direction
TACTL = TASSEL_1+MC_1; //ACLK, UPMODE
CCTL0 |= CCIE; //ENABLE
CCRO INTERUPT _EINT(); //Enable Global interrupts
}
void main(void)
{
init();
while(1)
{
LPM3; //Enter Low power mode
}
}
This code is unreadable; edit the question and use the "Insert code" button.
To make a pin an output, you have to set the bit in PxDIR.
**Attention** This is a public forum