本帖最后由 缥缈九哥 于 2012-9-14 12:11 编辑
M051 半主机调试测试
测试环境:IAR6.20 + Nu-link me + M0516
测试代码:
#include <stdio.h>
#include "DrvUART.h"
#include "DrvGPIO.h"
int main()
{
STR_UART_T sParam;
sParam.u32BaudRate = 115200;
sParam.u8cDataBits = DRVUART_DATABITS_8;
sParam.u8cParity = DRVUART_PARITY_NONE;
sParam.u8cStopBits = DRVUART_STOPBITS_1;
sParam.u8cRxTriggerLevel = DRVUART_FIFO_1BYTES;
sParam.u8TimeOut = 30;
DrvUART_Open (UART_PORT0, &sParam);
DrvGPIO_InitFunction(E_FUNC_UART0);
printf("Hello!\r\n");
while(1);
}
M051 不使用半主机调试(默认)
1、NuvotonPlatform_IAR\Src\Driver\retarget.c
//#define DEBUG_ENABLE_SEMIHOST /* To enable semihosted. !!!The SEMIHOSTED of startup_NUC1xx.s must be {TRUE} */
2、CMSIS\CM0\DeviceSupport\Nuvoton\M051Series\startup\iar\ startup_M051Series.s
SEMIHOSTED SET 0
3、编译结果:
4 662 bytes of readonly code memory
130 bytes of readonly data memory
1 444 bytes of readwrite data memory
4、运行结果:
M051 使用半主机调试
1、NuvotonPlatform_IAR\Src\Driver\retarget.c
#define DEBUG_ENABLE_SEMIHOST /* To enable semihosted. !!!The SEMIHOSTED of startup_NUC1xx.s must be {TRUE} */
2、CMSIS\CM0\DeviceSupport\Nuvoton\M051Series\startup\iar\ startup_M051Series.s
SEMIHOSTED SET 1
3、编译结果:
4 818 bytes of readonly code memory
130 bytes of readonly data memory
1 461 bytes of readwrite data memory
4、运行结果:
测试工程下载:
M0516半主机调试(IAR).rar
(269.29 KB)
|