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.

msp430g2452的ISP问题



我用的是CCSV5编程的,在配置USICNT时无法对它写入值,不知道这是为什么?而且无法跳出中断,我猜应该是因为USIIFG无法自动清零的原因吧。

下面是我的代码:

//SPI初始化程序
void SPI_INIT(void)
{
 //P1SEL |= BIT5 + BIT6 + BIT7 ;
 USICTL0 |= USIPE7 +  USIPE6 + USIPE5 + USIMST + USIOE; // Port, SPI master
 USICTL1 |=  USIIE;                     // Counter interrupt, flag remains set
 USICKCTL = USIDIV_1 + USISSEL_2;      // /2 SMCLK
 USICTL0 &= ~USISWRST;                 // USI released for operation
    P1DIR |= BIT0 + BIT1 + BIT2;
 //P1DIR |= 0x01;                        // Reset Slave
 //P1DIR &= ~0x01;
    USISRL = 0x46;
 delay_us(300);
  USICNT |= USICNT2 + USICNT1;                           // re-load counter
 //USIIFG = 0;                           // init-load counter
 //USICTL1 &= ~USIIFG;

}

uchar SPI_RW(uchar byte)
{
  delay_ms(1);
  while ((USIIFG & USICTL1));            // Counter clear?
  USISRL = byte;
//  USICNT = 8;                             // re-load counter
  delay_us(200);
  return USISRL;
}

// USI interrupt service routine
#pragma vector=USI_VECTOR
__interrupt void universal_serial_interface(void)
{
 // USISRL = *SPI_Data ;
  //USICNT |= BIT2;                           // re-load counter
 //USIFG = 0;
 USICNT |= USICNT2 + USICNT1;
  //USICTL1 &= ~USIIFG;
}