工具与软件:
我的团队已经确定了性能指标、即传输256字节数据包的功耗。 作为概念验证、我曾尝试为我的 MSP430 Launchpad 编写一个程序 unsigned char 阵列、 文本[256] 、用0至255的整数填充(即无符号8位整数的限制、以使事情变得简单)、然后 CPU 将每个字节发送到 UART 以供 CCS 中的控制台读取。
以 Brock Lameres 的 ADC 中断示例代码为指南、我尝试在字节被发送到缓冲区后将 MCU 切换到低功耗模式、然后在完成传输时触发 IRQ、以重新打开 CPU 并使其递增 无符号整型位置 . 遗憾的是、基于调试器中的单步执行程序、一旦 CPU 关闭、它看起来就会停止。
我缺少什么?
// Global variables unsigned char text[256]; // 256-byte array unsigned int position; // position in text // Main program int main(void) { WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer // Configure UART UCA1CTLW0 |= UCSWRST; // UART in software reset mode UCA1CTLW0 |= UCSSEL__SMCLK; // SMCLK as BRClk UCA1BRW = 8; // baud rate = 115.2k /* UCA1MCTLW = 0x2081; // 1,000,000 BRCLK, 9,600 baud, with 16x oversampling UCA1BRW = 6;*/ // Configure ports P4SEL1 &= ~BIT3; P4SEL0 |= BIT3; PM5CTL0 &= ~LOCKLPM5; // Take UART out of software reset UCA1CTLW0 &= ~UCSWRST; // Configure transmit interrupt UCA1IFG &= ~UCTXCPTIFG; // clear transmit complete flag UCA1IE |= UCTXCPTIE; // enable transmit complete interrupt __enable_interrupt(); // pre-populate array "text" with all possible positive 8-bit integers for (position = 0; position < 256; position++) text[position] = position; position = 0; // reset position // run loop while (1) { UCA1TXBUF = text[position]; // transmit current element of text // uncomment this and comment out next line if not using low-power mode // while (!(UCA1IFG & UCTXIFG)); __bis_SR_register(GIE | LPM0_bits); // enable maskable IRQs, } // turn off CPU for LPM return 0; } // Interrupt Service Routine; comment this out for non-low-power test #pragma vector = USCI_A1_VECTOR __interrupt void CyclePosition() { __bic_SR_register_on_exit(LPM0_bits); // wake up CPU if (position == 255) position = 0; else position++; // increment position UCA1IFG &= ~UCTXCPTIFG; // clear transmit complete flag }