Serial port printing, this is a good thing. The goal is to print the data transmitted from the board on the hyperterminal, that is, the data transmitted by the board can be displayed on the computer. This is relatively easy. I referred to the 2440lib.c file that comes with TQ. After initializing those reference chips and that c file, the program came out quickly. There are easier methods, but it is more impressive to write it yourself.
Keywords:TQ2440
Reference address:TQ2440 serial port data transmission
The procedure is as follows:
#include "2440addr.h"
#include "Option.h"
#include "def.h"
//Why doesn't it work once U32 is used?
unsigned int PCLK;
extern void Uart_Printf(char *fmt,...); //Function declaration, otherwise a warning will be displayed
extern void Uart_Select(int ch);
void delay(void) // Delay() is defined in 2440lib.c, but I accidentally redefined it. I was confused for a while
{
unsigned int i,j;
for(i=0;i<1000;i++)
for(j=0;j<1000;j++)
;
}
void My_uart_init(int mypclk,int mybuat) //Serial port initialization written by myself
{
unsigned int a;
rGPHCON = 0x0faaa; //0x1111 1010 1010 1010 select RTS, CTS, TXD, RXD
rGPHUP = 0x7ff; //Cancel all pull-up resistors [0; 10] A total of 11 I/O ports
if(mypclk == 0) //If it is 0, use the PCLK clock frequency in mpll. Here I used 50MHz, and it must be 50MHz
mypclk = PCLK; //Isn't the PCLK of mpll 50MHz? If you set mypclk to 0, it should be OK, but I haven't tried it.
rUFCON0 = 0x0;
rUFCON1 = 0x0;
rUFCON2 = 0x0; //FIFO disabled
rUMCON0 = 0x0;
rUMCON1 = 0x0; //Disable AFC, etc.
rULCON0 = 0x3; //Transmission word length 8 bytes
rUCON0 = 0x245; // [0,3] is reserved and cannot be set. Set Rx error status interrupt and Tx level interrupt. The settings of serial ports 1 and 2 are the same
rUBRDIV0 = ((int)(mypclk/(mybuat*16)))-1; // Provide serial clock for transmitter and receiver, see chip manual for calculation formula
rULCON1 = 0x3;
rUCON1 = 0x245;
rUBRDIV1 = ((int)(mypclk/(mybuat*16)))-1;
rULCON2 = 0x3;
rUCON2 = 0x245;
rUBRDIV2 = ((int)(mypclk/(mybuat*16)))-1;
for(a=0;a<100;a++);//delay, refer to 2440lib.c, my personal understanding should be
}
void Main(void)
{
Uart_Select(0); //Select serial port 0
My_uart_init(50000000,115200); // Give the clock 50MHz, baud rate 115200 serial port to work
Uart_Printf("\n\n"); //Test whether the input \n in 2440lib.c will be supplemented with \r, carriage return and line feed
delay();
while(1)
{
Uart_Printf("I love caimanjun more than myself\n"); //Print string
delay();
Uart_Printf("yes I do! \n");
delay();
}
}
Previous article:TQ2440 key interrupt
Next article:TQ2440's simplest serial port data transmission
Recommended ReadingLatest update time:2024-11-16 14:41
TQ2440 linux i2c driver - at24c02 (eeprom)
1. Development environment: (1) Development board: TQ2440 development board (2) PC system: Ubuntu 13.04-amd64 (3) Interleaved compiler: arm-linux-gcc version-4.3.3 (4)linux kernel:linux 2.6.30。4 2. Introduction to the i2c system (Here are some words about the structure, taken from the Internet) I2C is a peripheral b
[Microcontroller]
Research on Touch Screen Driver Based on TQ2440 and Linux
Embedded technology is becoming more and more popular in industry and daily life. As an interactive terminal, touch screens have gradually replaced keyboards as input devices for embedded systems. Using the TQ2440 development board, we studied the touch screen driver in the embedded Linux kernel, wrote and transplan
[Microcontroller]
u-boot-1.1.6 transplantation based on TQ2440 (basic steps)
References: "Transplanting u-boot-1.1.6 to TQ2440 Documentation" Tianqian transplanted source code Migration environment System: Ubuntu 12.04 built by Huaqing Yuanjian virtual machine Development board: TQ2440 Cross compiler: crosstools_3.4.5_softfloat CPU:S3C2440 SDRAM: 64M NOR Flash:2M NAND Flsah:256M NET:DM9000
[Microcontroller]
- Popular Resources
- Popular amplifiers
Latest Microcontroller Articles
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
MoreDaily News
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
Guess you like
- SHT31 Review - In-depth Review
- 【McQueen Trial】+ Unboxing and Assembly
- Using nRF24L01 with MicroPython
- [Help Post] High-frequency oscillation of high-frequency switching power supply current
- SHT31 Review - Unboxing and First Impressions
- IoT security himqtt firewall data structure ringbuffer ring buffer
- EEWORLD University Hall----Live Replay: TI's Latest Application of Millimeter-Wave Radar in the Automotive Field
- Changes in car rear lighting design
- EEWORLD University - Tektronix will teach you the oscilloscope usage skills you don't know
- [Download Gift] Demonstrate Multi-channel Signal Spectrum Analysis Using the Spectrum View Function of the New Tektronix MSO6 Oscilloscope