SH-stick serial port emulator, the study of Renesas microcontroller, or the simplest program to start, LED on and off, button control, equivalent to C language Hello world! The program includes the following parts: system initialization (FRQCR); I/O initialization; LED initialization; main program
//#include "typedefine.h"
#ifdef __cplusplus
//#include
//_SINT ios_base::Init::init_cnt; // Remove the comment when you use ios
#endif
#ifdef __cplusplus
extern "C" {
void abort(void);
#endif
void main(void);
#ifdef __cplusplus
}
#endif
#include "iodefine.h"
#include "machine.h"
VOID InitClock( );
VOID InitPort( );
VOID InitLED( );
VOID InitKey( );
VOID Delay();
VOID Flaled();
VOID main( ){
InitClock(); //Initialize the clock
InitPort(); //Initialize the port function
InitLED(); //Initialize the LED port
InitKey(); //Initialize the key interrupt (IRQ0)
while(1)
{
if(INTC.IRQSR.BIT.IRQ0F==1) //Judge whether an IRQ0 falling edge interrupt occurs
{
INTC.IRQSR.BIT.IRQ0F=0; //If an interrupt occurs, clear the interrupt flag
if(INTC.IRQSR.BIT.IRQ0F==0) //Read the interrupt flag again to ensure that the interrupt flag is cleared before taking the next step
{
Flaled();
}}
/*/
VOID Flaled( )
{
PE.DRL.WORD = 0x05FF; // 所有LED点亮
Delay(3000);
PE.DRL.WORD = 0xFA20; // 关所有LED
Delay(3000);
}
//
VOID Delay(unsigned int z)
{
unsigned int i=0,j=0;
for(i=z;i>0;i--)
{
for(j=1000;j>0;j--);
}
}
//
VOID InitClock(){
CPG.FRQCR.WORD = 0x16DB; //Use 48MHz as internal clock and 24MHz as MTU2 clock
}
/*
//
VOID InitPort(){
PFC.PACRL1.BIT.PA2MD = 3; //PA2 is used as IRQ0 input function.
PFC.PBCRL2.BIT.PB5MD = 1; //PB5 is used as IRQ3 input function.
PFC.PEIORL.BIT.B5 = 1; //PE5 is used as output port
}
//
VOID InitLED(){
// PE.DRL.WORD = 0x05FF; // LEDs are all on
PFC.PEIORL.WORD |= 0xFA00; // PE15,14,13,12,11,9 are used as general I/O ports
}
//
VOID InitKey(){
INTC.IRQCR.BIT.IRQ0S = 1; //Detect interrupt request on falling edge
INTC.IPRA.BIT._IRQ0 = 9; //Set interrupt priority of IRQ0
}
#ifdef __cplusplus
void abort(void)
{
}
#endif
Previous article:Hardware construction and operation process of Renesas MCU serial port download simulation program
Next article:My Introduction to Renesas MCU
- Popular Resources
- Popular amplifiers
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
- Record the use of TM1668 driver
- Newbie help, ESP8266 program problem
- The principle of I2C bus digital potentiometer and its interface design with single chip microcomputer
- Keysight Technologies 1688 Online Store Offers 50% Off E5061B Network Analyzer in April
- GaN Applications in RF and Electronics
- CC2530 Basic Experiment 1 I/O Experiment Code
- DC motor drive solution using TC118S domestic chip
- Inline instructions in TI DSP TMS320C66x study notes (c6x.h Chinese comments)
- [Zero-knowledge ESP8266 tutorial] Quick Start 19 Using NTP server to get network time
- [GD32E503 Review] How to Play with GD32E503-Environment Construction