顺便分享一下我修改后的代码,适合官方的开发板
/*---------------------------------------------------------------------------------------------------------*/
/* */
/* Copyright(c) 2019 Nuvoton Technology Corp. All rights reserved. */
/* */
/*---------------------------------------------------------------------------------------------------------*/
//***********************************************************************************************************
// Website: http://www.nuvoton.com
// E-Mail : MicroC-8bit@nuvoton.com
//***********************************************************************************************************
//***********************************************************************************************************
// File Function: ML51 simple GPIO toggle out demo code
//***********************************************************************************************************
#include "ML51.h"
/**
* [url=home.php?mod=space&uid=247401]@brief[/url] GPIO input output demo
* @param None
* [url=home.php?mod=space&uid=266161]@return[/url] None
* [url=home.php?mod=space&uid=1543424]@Details[/url] GPIO toggle and UART0 TXD0 send out.
*/
void main (void)
{
MFP_P23_GPIO;
P23_INPUT_MODE;
// ENABLE_P23_PULLUP;
ENABLE_P23_PULLDOWN;
MFP_P03_GPIO;
P03_PUSHPULL_MODE;
/*
For UART0 P3.1 as TXD output setting
* include uart.c in Common Setting for UART0
*/
MFP_P31_UART0_TXD; // UART0 TXD use P1.6
P31_QUASI_MODE; // set P1.6 as Quasi mode for UART0 trasnfer
UART_Open(24000000,UART0_Timer1,115200); // Open UART0 use timer1 as baudrate generate and baud rate = 115200
while(1)
{
while (P2&SET_BIT3); // P23 = 1;
while (!(P2&SET_BIT3)); // P23 = 0;
P03 ^=1;
/* include timer.c for delay setting */
Timer2_Delay(24000000,128,100,1000);
UART_Send_Data(UART0,0x55);
}
}
|