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);
}
}
Previous article:Nuvoton N76e003 MCU Program Analysis
Next article:N76E003 serial port receives string and outputs it completely
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- ASML predicts that its revenue in 2030 will exceed 457 billion yuan! Gross profit margin 56-60%
- Detailed explanation of intelligent car body perception system
- How to solve the problem that the servo drive is not enabled
- Why does the servo drive not power on?
- What point should I connect to when the servo is turned on?
- How to turn on the internal enable of Panasonic servo drive?
- What is the rigidity setting of Panasonic servo drive?
- How to change the inertia ratio of Panasonic servo drive
- What is the inertia ratio of the servo motor?
- Is it better for the motor to have a large or small moment of inertia?
- "Vivado Starts Here" - Quickly Get Started with Vivado
- If the PCB heat dissipation area is not enough, will increasing the copper thickness help improve the heat dissipation of the PCB?
- Can't tell the difference? The difference between RF analog signal source and vector signal source
- Most EMI problems are related to clock signals.
- [Xiao Meige SoC] How to view the number of GPIO added on the FPGA side of the SoC FPGA system and use interrupts
- What are the two parts of RFID?
- How to use the virtual serial port VCOM function of J-Link?
- HD7279A controls digital tube (IAR environment)
- This mood light seems more suitable for festivals
- Bumpy B-U585I-IOT02A review, BLE