Hi everyone;
my program don't enter PORT1_VECTOR ISR second time. It enter first time,but don't enter secondly unless reset the msp430.
* My project, reading RTC & send through UART using ISR
* I use button on P1.4 for enter ISR
* In ISR, i read second via USCI (SPI) & send via USCI(UART) , after read and send minute, it is easy.
my program
#include <msp430.h>
#include "pcf2123_reg.h"
unsigned short i;
unsigned short j;
unsigned char sec ;
unsigned char hour ;
void ClockConfig()
{
BCSCTL1 = CALBC1_8MHZ;
DCOCTL = CALDCO_8MHZ;
BCSCTL2= DIVS_3 + DIVM_0;
BCSCTL3 |= LFXT1S_2;
//MCLK =DCO
//SMCLK=DCO/8
}
void PinConfig()
{
P1SEL = BIT1+BIT2+ BIT5 + BIT6 + BIT7;
P1SEL2 = BIT1+BIT2+ BIT5 + BIT6 + BIT7;
P1DIR |= BIT0+BIT3;
P1OUT |= BIT0+BIT3+BIT4;
P1IE |= BIT4; // P1.4 interrupt enabled
P1IES |= BIT4; // P1.4 Hi/lo edge
P1REN |= BIT4; // P1.4 pullup
P1IFG &= ~BIT4; // P1.4 IFG cleared
}
void UartConfig(){
UCA0CTL1 = UCSSEL_2;
UCA0BR0 = 104;
UCA0BR1 = 0;
UCA0MCTL = UCBRS0;
UCA0CTL1 &= ~UCSWRST;
}
void SpiConfig()
{
//USCI initialization and configuration
UCB0CTL1 = UCSWRST;
UCB0CTL0 |= UCMST + UCMODE_0 + UCSYNC + UCMSB + UCCKPH ;
UCB0CTL1 |= UCSSEL_2;
//Master,3 pin SPI,Senkron,MSB first,..,..
//Source:SMCLK
UCB0BR0 = 4;
UCB0BR1 = 0;
//Bit Rate
//UCB0MCTL = 0;
//SPI modda modülasyon kullanılmaz
UCB0CTL1 &= ~UCSWRST;
//USCI modül RX ve TX'e hazır
}
int main(void) {
WDTCTL = WDTPW | WDTHOLD;
ClockConfig();
PinConfig();
SpiConfig();
UartConfig();
_BIS_SR(LPM4_bits + GIE);
}
// Port 1 interrupt service routine
#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{
read_rtc(cmd_rd_seconds,&sec);
UCA0TXBUF = bcd_to_dec(sec) + 80 ;
while(!(IFG2 & UCA0TXIFG));
read_rtc(cmd_rd_minutes,&hour);
UCA0TXBUF = bcd_to_dec(hour) + 80 ;
while(!(IFG2 & UCA0TXIFG));
P1OUT ^= 0x01;
P1IFG &= ~BIT4;
P1IFG = 0;
}