N76E003AT20 MCU serial port 0 debugging

Publisher:xxoke624Latest update time:2022-07-11 Source: csdnKeywords:N76E003AT20 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

If a key 1 is pressed, the serial port 0 of N76E003 will send 1 to the serial port debugging assistant, but there is always a problem. Which great god can help me? The code is as follows:

#include "n76e003.h"

#include "stdio.h"

#define uint32 unsigned int

//typedef unsigned int uint32;

void delay_us(int n)

{

int m;

for(m=0;m

}

void delay_ms(int j)

{

int k;

for(k=0;k

delay_us(1000);

}

void P0_P1_Mode(void)

{

P0M1=0x3A; P0M2=0x3B; //Set P0

P1M1=0xA0; P1M2=0xBF; //Set P1

}

sbit s1 = P0^0;

sbit s2 = P1^0;

sbit s3 = P1^1;

sbit s4 = P1^2;

sbit s5 = P1^3;

sbit s6 = P1^4;

void UART0_Init(uint32 Baud) //Set up serial port 0

{

P0_P1_Mode();

ES=1; //Enable all interrupts

ES=1; //Serial port 0 interrupt enable

ET1=0; //Disable timer 1 interrupt

SCON = 0x52; //Serial port 0 selects mode 1 SM0=0 SM1=1 REN=1 TI=1

T3CON|=0x00; //Select timer 1 BRCK=0

PCON |= 0x80; // Double the baud rate of timer 1 SMOD=1

CKCON|=0x10; //The clock source of timer 1 is the system clock T1M=1

TMOD |=0x20; //Timer 1 selects mode 2 8-bit counter, the value is automatically reloaded from TH1 to TL1 M1=1 M0=0 2^8=256

#ifdef FOSC_160000

TH1 = 256 - (1000000/Baud+1); /*16 MHz */

#endif

TCON |=0x40; //Timer 1 starts TR1=1

}

void Send_Data_UART0(int a)

{

TI=0;

SBUF=a; //Serial port 0 data buffer register

while(TI==0);

}

int main()

{

s1=1;

s2=1;

s3=1;

s4=1;

s5=1;

s6=1;

UART0_Init(9600);

while(1)

{

if(s1=0)

{ Send_Data_UART0(1); }

delay_ms(10);

if(s2=0)

{ Send_Data_UART0(2); }

delay_ms(10);

if(s3=0)

{ Send_Data_UART0(3); }

delay_ms(10);

if(s4=0)

{ Send_Data_UART0(4); }

delay_ms(10);

if(s5=0)

{ Send_Data_UART0(5); }

delay_ms(10);

if(s6=0)

{ Send_Data_UART0(6); }

delay_ms(10);

}

}


Keywords:N76E003AT20 Reference address:N76E003AT20 MCU serial port 0 debugging

Previous article:Nuvoton N76e003 MCU Program Analysis
Next article:N76E003 serial port receives string and outputs it completely

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号