|
我采用MSP430F5638的UCA0 与 TMS320F28335的Scic口进行通信:
MSP430F5638的程序如下:
- #include <intrinsics.h>
- #include <string.h>
- #include "msp430.h"
- #include "driverlib/MSP430F5xx_6xx/flash.h"
- #include "driverlib/MSP430F5xx_6xx/wdt_a.h"
- #include "driverlib/MSP430F5xx_6xx/ucs.h"
- #include "driverlib/MSP430F5xx_6xx/pmm.h"
- #include "driverlib/MSP430F5xx_6xx/sfr.h"
- #include "driverlib/MSP430F5xx_6xx/inc/hw_memmap.h"
- #include "IQmathLib.h"
- #include "hal.h" // Modify hal.h to select your hardware
- #include "Main_F5528_Scan.h"
- void INIT_SciB_Char(void);
- void main(void)
- {
- WDTCTL = WDTPW + WDTHOLD; // Stop Watchdog Timer
- // for 24MHz MCLK, below.
- PMM_setVCore(PMM_BASE, PMM_CORE_LEVEL_3);
- initPorts(); // Config all the GPIOS for low-power (output low)
- initClocks(24000000); // Config clocks.
- P8SEL |= BIT2 + BIT3; // P3.3,4 = USCI_A0 RXD/TXD 触摸屏通信
- UCA1CTL1 |= UCSWRST; // 重置UCA0
- UCA1CTL1 |= UCSSEL_2; // SMCLK 6MHz
- UCA1BR0 = 0x71; // 波特率9600
- UCA1BR1 = 0x02; // 波特率9600
- UCA1MCTL = 0x00; // No Modulation
- UCA1CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
- P2SEL |= BIT4 + BIT5; // P4.4,5 = USCI_A1 RXD/TXD F28335通信
- UCA0CTL1 |= UCSWRST; // 重起UCA1
- UCA0CTL1 |= UCSSEL_2; // SMCLK 6MHz
- UCA0BR0 = 0x34; // 波特率1152000
- UCA0BR1 = 0x00; // 波特率115200
- UCA0MCTL = 0x40;
- UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
- // setup watchdog as 1 second timer 设置在看门狗模式看门狗定时器的时钟源。
- // WDT_A_watchdogTimerInit(WDT_A_BASE,WDT_A_CLOCKSOURCE_SMCLK,WDT_A_CLOCKDIVIDER_512K);
- // WDT_A_start(WDT_A_BASE);
- UCA0IFG = 0x00; // 清UCA0中断标识
- UCA0IE = 0x01; // 使能UCA0中断;
- UCA0IE |= UCRXIE; // 使能UCA0接收中断;UCRXIE
- UCA1IFG = 0x00; // 清UCA1中断标识
- UCA1IE = 0x01; // 使能接收中断;
- UCA1IE |= UCRXIE; // 使能UCA1接收中断
- UCS_getSMCLK(UCS_BASE);
- UCS_getMCLK(UCS_BASE);
- UCS_getACLK(UCS_BASE);
- __enable_interrupt(); // enable interrupts
- TX_FuncNO = 4;
- for(;;)
- {
- }
- }
- #pragma vector=USCI_A0_VECTOR
- __interrupt void USCI_A0_ISR(void)
- {
- while (!(UCA0IFG&UCRXIFG)); // USCI_A0 TX buffer ready?
- RSciA_Char = UCA0RXBUF;
- UCA0IFG = 0x00;; //MSP430 清UCA1中断标识
- }
- //*****************************************************************************
- // UART1中断服务子程序。接收触摸屏菜单指令并处理
- //*****************************************************************************
- #pragma vector=USCI_A1_VECTOR
- __interrupt void USCI_A1_ISR(void)
- {
- TX_FuncNO = 4;
- //取F28335 存放的样本数据
- while(UCA0STAT && UCBUSY){};
- UCA0TXBUF = TX_FuncNO; //发送功能号第1个字节,
- while(UCA0STAT && UCBUSY){};
- UCA0TXBUF = TX_FuncNO >> 8; //发送功能号第2个字节,
- UCA1IFG = 0x00;; //MSP430 清UCA0中断标识
- }
复制代码 问题是:当TMS320F28335连续不断的发送时,MSP430F5638的UCA0会发生读入中断; 但当TMS320F28335单一发送一两个字符时读入中断就不会发生.
这是什么原因呢?怎么解决?
|
|