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.

[参考译文] MSP432E401Y:适用于 MSP432E401Y 的 UART ISR

Guru**** 2537350 points


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

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/900100/msp432e401y-uart-isr-for-msp432e401y

器件型号:MSP432E401Y

您好!

我的代码与处理不正确 ISR 的默认处理程序不断进入无限循环、我不知道我做了什么错误、这是我的代码、 我希望 ISR 将接收到的字符放入我创建的环形缓冲器中、并继续执行它正在执行的任何操作。

//将时钟设置为直接从频率为120MHz 的晶体运行。
//
G_ui32SysClock = SysCtlClockFreqSet ((SYSCTL_XTAL_25MHz |
SYSCTL_OSC_MAIN |
SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_480)、120000000);
//
//启用用于板载 LED 的 GPIO 端口。
//
SysCtlPeripheralEnable (SYSCTL_Periph_GPION);

//
//为 LED (PN0)启用 GPIO 引脚。
//
GPIOPinTypeGPIOOutput (GPIO_PORTN_BASE、GPIO_PIN_0);

//
//启用此示例使用的外设。
//
SysCtlPeripheralEnable (SYSCTL_Periph_UART0);
SysCtlPeripheralEnable (SYSCTL_Periph_GPIOA);

//
//启用处理器中断。
//
IntMasterEnable();

//
//将 GPIO A0和 A1设置为 UART 引脚。
//
GPIOPinConfigure (GPIO_PA0_U0RX);
GPIOPinConfigure (GPIO_PA1_U0TX);
GPIOPinTypeUART (GPIO_Porta_base、GPIO_PIN_0 | GPIO_PIN_1);

//
//将 UART 配置为115、200、8-N-1操作。
//
UARTConfigSetExpClk (UART0_BASE、g_ui32SysClock、115200、
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));
休眠计数器模式(HIBERNATE_COUNTER_RTC);
//
//启用 UART 中断。
//
IntEnable (INT_UART0);
UARTIntEnable (UART0_BASE、UART_INT_RX | UART_INT_RT);

//
//
// UART 中断处理程序。
//
//

空 UART0_IRQHandler (空)

uint32_t ui32Status;
//
//获取中断状态。
//
ui32Status = UARTIntStatus (UART0_BASE、TRUE);
//
//清除已发出的中断。
//
UARTIntClear (UART0_BASE、ui32Status);
//
//在接收 FIFO 中有字符时循环。
//
while (UARTCharsAvail (UART0_BASE))

int32_t byte = UARTCharGetNonBlocking (UART0_BASE);
Coordinator.gpsManager.pbuffer.push (字节);