/*---------------------------------------------------------------------------------------------------------*/
/* */
/* 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_P46_GPIO;
P31_PUSHPULL_MODE;
MFP_P50_GPIO;
P50_PUSHPULL_MODE;
MFP_P51_GPIO;
P51_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)
{
SFRS = 0;
P46 ^= 1;
while (P5|CLR_BIT6); // P56 = 1;
while (!(P5&SET_BIT6)); // P56 = 0;
/* include timer.c for delay setting */
Timer2_Delay(24000000,128,100,1000);
UART_Send_Data(UART0,0x55);
}
}
while (P5|CLR_BIT6); // P56 = 1;
while (!(P5&SET_BIT6)); // P56 = 0;
这里两句怎么理解
查了下
CLR是该位为0,SET为该位为1
那么跟P5或了之后,不是没有任何影响吗,怎么能判断是否等于1呢?根据定义这个会一直为真啊。。
还有下面这个zu56为1,组合就为真,取反为假,,跳过了
如果56为0,那么为假,取反为真,等待。。
这个可以懂。上面这个不懂了。
|