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.

[参考译文] CCS/MSP430F5132:MSP430在固定UART传输计数后停止工作

Guru**** 2538300 points
Other Parts Discussed in Thread: ISO3088, MSP430F5132, MSP430F5529

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/616196/ccs-msp430f5132-msp430-stops-working-after-a-fixed-uart-transmit-count

部件号:MSP430F5132
主题中讨论的其他部件:ISO3088MSP430F5529

工具/软件:Code Composer Studio

您好,

我正在使用由MSP430F5132IDA控制的RS485设备。 以下是有关我的自定义设备的注释:

- MSP430F5132是板载MCU,它使用ISO3088 TI器件进行I/O和RS485通信。

如果我不使用任何UART,一切都正常。  

-如果MCU向PC传输,一切都正常。

——如果MCU收到命令(如“36.0751万SETO1#”)并回复字符串“ACK36.0751万”,则在传输第88个字符串后失败(我不知道为什么是88,我设置了一些禁用中断,清除中断并启用内部代码,它增加到第19位)。 MCU完全停止,无状态LED闪烁。 卡在延迟位置(2万))

以下是PC侧的屏幕打印:

以下是用于UART通信的简单MSP430F5132代码(来自MSP430F5529示例):

#include "driverlib.h"

#define Status1 GPIO PIO_PIN6
#define STATUS2 GPIO PIN5

#define IN1 GPIO PIN4
#define in2 GPIO _PIN5
#define in3 GPIO _PIN6
#GPIO IN4 GPIO GPIO _PIN7
#define iN5
GPIO _PIN0 #define IN6



GPIO #IN1 OUPIN5






进8进1内定义GPIO 8进8进1进1进1进1进1进1进8进8进 0x00;

uint8_t check = 0,sendack=0,donguKontrol = 0;
uint8_t sendMessage = 1,receiveEnable = 0,charReceived = 0;

char charArray[12],charArrayCopy[12];

volatile int I,c=0;
UINT8_t receivedData = 0x00;


void main (void)
{
//停止WDT
WDT_A_HOLD (WDT_A_BASE);

//outs低位优先,防止输出处闪烁
GPIO_setOutputHighOnPin (GPIO端口P2,OUT5 + OUT4 + OUT3);
GPIO_setOutputHighOnPin (GPIO端口P3,OUT2 + OUT1 + STATUS2 +状态1);

//输出
GPIO_setAsOutputPin (GPIO端口P2,OUT5 + OUT4 + OUT3);
GPIO_setAsOutputPin (GPIO端口P3,OUT2 + OUT1 + STATUS2 +状态1);

GPIO_setOutputHighOnPin (GPIO端口P2,OUT5 + OUT4 + OUT3);
GPIO_setOutputHighOnPin (GPIO端口P3,OUT2 + OUT1);
GPIO_setOutputLowOnPin (GPIO端口P3,STATUS2 +状态1);

//输入
GPIO_setAsInputPin (GPIO端口P1,IN1 + in2 + in3 + IN4);
GPIO_setAsInputPin (GPIO端口P2,iN5 + IN6);

//RS485 de Re
GPIO _setAsOutputPin (GPIO端口P1,GPIO _PIN0 + GPIO _PIN3);

//UART - RS485
GPIO _setAsPeripheralModuleFunctionInputPin (GPIO_PORT_P1, GPIO _PIN1 + GPIO PIN2);



//Baudrate = 9600,时钟频率= 1.048MHz
//UCBRx =109,UCBRFx =0,UCBRSx =2,UCOS16 =0 -->从MSP430F5529示例复制
USI_A_UART_initParam ={0};
param.selectClockSource = USI_A_UART_CLOCKSOURCE_SMCLK;
Param.clockPrescalar = 109;
Param.firstModReg = 0;
param.secondModReg = 2;
Param.parity = USI_A_UART_NO_PARTIC;
Param.msborLsbFirst = USI_A_UART_LSB_FIRST;
StopBits的Param.Number= USI_A_UART_OON_STOP_BIT;
Param.uartMode = USI_A_UART_MODE;
Param.oversampling = USI_A_UART_LLOW频率_BAUDRATE_RELEA;

IF (STATUS_FAIL == USI_A_UART_INIT (USI_A0_BASE,&param))
{
返回;
}

//启用UART模块以进行操作
USI_A_UART_ENABLE (USI_A0_BASE);

//启用接收中断
USI_A_UART_CLEARInterrupt (USI_A0_BASE,USI_A_UART_receive中断);
USI_A_UART_enableInterrupt (USI_A0_BASE,USI_A_UART_receive中断);


__enable_interrupit();

同时(1)
{
IF (charReceived == 1){

GPIO _setOutputHighOnPin (GPIO端口P1,GPIO _PIN0 + GPIO _PIN3);
_DELAY周期(8000);

USI_A_UART_SDEARData (USI_A0_BASE,'A');
USI_A_UART_SDEARData (USI_A0_BASE,'C');
USI_A_UART_SDEARData (USI_A0_BASE,'K');
USI_A_UART_SDEARData (USI_A0_BASE,'3');
USI_A_UART_SDEARData (USI_A0_BASE,'6');
USI_A_UART_SDEARData (USI_A0_BASE,'0');
USI_A_UART_SDEARData (USI_A0_BASE,'7');
USI_A_UART_SDEARData (USI_A0_BASE,'5');
USI_A_UART_SDEARData (USI_A0_BASE,'1');
USI_A_UART_HESARData (USI_A0_BASE,'?');


_DELAY周期(8000);
GPIO _setOutputLowOnPin (GPIO端口P1,GPIO _PIN0 + GPIO _PIN3);

CharReceived = 0;
}

GPIO_setOutputHighOnPin (GPIO端口P3,状态1);
_DELAY周期(2万);
GPIO_setOutputLowOnPin (GPIO端口P3,状态1);
_delay_cycles(2万);

}
}//**************************************************************************************************************



////
这是USI_A0中断向量服务例程。
////************************************************************************************************

#if defined(__TI_Compiler_version__)|| defined(__IAR_systems_ICC__)
#pragma vector=USI_A0_vector
__interrupt
#Elif defined(__Gnuinu_)
__attribute__((interrupt (USI_A0_vector))
#endif
void USI_A0_ISR(void)
{
Switch(__偶 数_in_range(UCA0IV,4))
{
//矢量2 - RXIFG
案例2:
receivedData = USI_A_UART_receiveData (USI_A0_BASE);

IF (已接收数据!='#') //检查值
{
charArray[c]=已接收数据;
C++;
CharReceived = 0;
其他{
CharReceived = 1;
}
中断;
默认值:break;
}
}

期待您的建议。

此致,

奥努尔

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    您好Onur:

    看起来您正在USCI_A0_ISR中递增数组索引“c”,但在收到所有预期的UART字符后,不将其重置为零。 您的数组"charArray"也只有12个元素。 我建议在while ()循环内的IF()语句中重置"charReceived =0"的位置附近添加"c =0"。

    此致,

    詹姆斯

    MSP客户应用程序
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好,

    我很抱歉。 现在没关系。 传输计数为4000多个并在增加。

    谢谢!

    奥努尔

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    您好Onur:

    无需道歉。 我的建议是否解决了您的问题?

    此致,

    詹姆斯

    MSP客户应用程序