HI~各位
請問 當我執行simplelink_msp432_sdk_1_40_01_00 裡面的範例
C:\ti\simplelink_msp432_sdk_1_40_01_00\examples\rtos\MSP_EXP432P401R\drivers\timerled
當 timerCallback 只有執行 GPIO_toggle(Board_GPIO_LED0); 不會有錯誤。
但是當我將timerCallback內容修改為 UART_write(uart, echoPrompt, sizeof(echoPrompt)); 則會出現不正常錯誤
下面是我修改過的code
不知哪邊出了問題?
/*
* ======== timerled.c ========
*/
#include <stddef.h>
/* Driver Header files */
#include <ti/drivers/GPIO.h>
#include <ti/drivers/Timer.h>
#include <ti/drivers/UART.h>
/* Board Header file */
#include "Board.h"
/* Callback used for toggling the LED. */
void timerCallback(Timer_Handle myHandle);
/*
* ======== mainThread ========
*/
UART_Handle uart;
const char echoPrompt[] = "Echoing characters:\r\n";
void *mainThread(void *arg0)
{
UART_Params uartParams;
/* Period and duty in microseconds */
Timer_Handle timer0;
Timer_Params params;
/* Call driver init functions */
GPIO_init();
Timer_init();
UART_init();
/* Turn off user LED */
// GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_OFF);
/* Create a UART with data processing off. */
UART_Params_init(&uartParams);
uartParams.writeDataMode = UART_DATA_BINARY;
uartParams.readDataMode = UART_DATA_BINARY;
uartParams.readReturnMode = UART_RETURN_FULL;
uartParams.readEcho = UART_ECHO_OFF;
uartParams.baudRate = 115200;
uart = UART_open(Board_UART0, &uartParams);
/* Setting up the timer in continuous callback mode that calls the callback
* function every 1,000,000 microseconds, or 1 second.
*/
Timer_Params_init(¶ms);
params.period = 1000000;
params.periodUnits = Timer_PERIOD_US;
params.timerMode = Timer_CONTINUOUS_CALLBACK;
params.timerCallback = timerCallback;
timer0 = Timer_open(Board_TIMER0, ¶ms);
if (timer0 == NULL) {
/* Failed to initialized timer */
while (1);
}
if (Timer_start(timer0) == Timer_STATUS_ERROR) {
/* Failed to start timer */
while (1);
}
return (NULL);
}
/*
* This callback is called every 1,000,000 microseconds, or 1 second. Because
* the LED is toggled each time this function is called, the LED will blink at
* a rate of once every 2 seconds.
* */
void timerCallback(Timer_Handle myHandle)
{
GPIO_toggle(Board_GPIO_LED0);
UART_write(uart, echoPrompt, sizeof(echoPrompt));
}