Getting started with AVR MCU + using keil-MDK to run TQ2440

Publisher:QuantumPulseLatest update time:2019-11-30 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

I haven't updated my blog for two or three months. In the past two months, I have been learning AVR microcontrollers. The complexity of the chip has increased a lot. I read the 300-page data sheet three times before I had a general understanding. Next, I have to do experiments to familiarize myself with each module. I found an excellent introductory book "Microcontroller C Language Programming Training-Based on AVR PROTEUS Simulation" by Teacher Ma Chao. So far, the only basic exercises I have not done are the communication between the host and the slave and the watchdog experiment. Unfortunately, the overall difficulty of the "homework" assigned by this book is not high. Some of the homework that I can think of the solution at a glance did not do, and I did not miss any of the homework that I thought I didn't know how to do.


Every time you start learning a new type of microcontroller, you need to do the following:

1) Choose the right microcontroller chip

2) Choose a suitable development environment

3) Choose the right burning tool

4) Learn to write naked programs to familiarize yourself with the resources on the microcontroller chip

Only in this way can we start application-level development. Based on the needs of game development, I chose atmega1284P and AVR Studio 4 as the development environment. The fifth generation was troublesome to install and could not work with the winAVR compiler, which resulted in the _delay_us(variable) method failing to compile. Only constants could be used as delay parameters. This bug was too annoying, so I had no choice but to switch to the fourth generation + winAVR. I have used IAR in other development environments on the Internet, and I prefer the interface provided by gcc in comparison, so I finally decided to use AVR Studio 4. There is no need to burn, because all simulations are done using proteus. The way of experimentation afterwards was similar to that on 51, which was to experiment with each on-chip resource one by one.


Another month has passed. I have completed the experiment of LCD controller T6963C. A serious problem has emerged: the efficiency of drawing pixels and geometric figures based on the graphic LCD with one pixel occupying 1 bit is extremely low. The reading and writing data are at least 8 bits, that is, in bytes. In this way, if you want to write a pixel, you need

1) Read the byte where the pixel is located

2) Change the corresponding bit

3) Write back to video memory

The result of drawing pixels in this way is that the physical particle effect I hope for cannot be achieved. Maybe this inefficient method can also achieve particle effects, but I didn't try it. Look at the early games like "Tetris" and "Push Box", which are not smooth. In this way, unnecessary bit operations can be avoided and the operation granularity can be enlarged to bytes. Even for games like "Snake" that seem to move smoothly, its frame rate is much lower than that of ordinary games, so inefficient pixel operations can be tolerated. What I want to do is a game based on sprite animation, which requires smooth movement of an image. If a 1-bit pixel LCD does not have a bit-level block copy, it will be extremely troublesome to implement. The only way I can think of is to use an LCD with a serial interface, so that bits can be added before and after the data to achieve data translation.


On the other hand, there are AVR microcontrollers with TFT displays for sale online, so my other option is to buy an AVR development board and continue my experiments on it. I already have an ARM7 board and an ARM9 board with a touch screen. After careful consideration, I decided to upgrade to the ARM platform. I bought the ARM9 board three years ago, so I should be able to handle it now. 


There was no choice for the CPU, which was S3C2440. I knew that I couldn't choose the outdated ADS as the development environment. The extremely unfriendly compilation error message was simply frustrating. I searched and found that I could use keil, which was great. I downloaded the MDK4.5 evaluation version from the ARM official website, and burned it with the J-link that I bought at the same time as the board. After debugging, it worked normally. But the last step of "running naked" took me several days. The methods on the Internet had some problems. The root cause was that ARM's startup Flash has two types, Nor and Nand, and there are also two startup methods. So I referred to a lot of information on the Internet and learned and understood the startup process before I finally made the LED light up correctly. Due to the limitation of the number of flash writes, the ideal way to run naked is to download it directly to RAM to run the program. The hard work of several days was not in vain.

 

Keil-MDK naked TQ2440 key points:

I. Understanding of the startup process. 

The bare-bones booting of 51 MCU and AVR MCU is very simple, just download the compiled hex file to the MCU, so there is no complicated address configuration. ARM is different, you can boot from Nor flash memory or Nand flash memory.

The following picture is taken from the S3C2440A datasheet.

 

1) The left picture may be the boot memory map of the Nor flash memory, which should be replaced by other roms, such as eeprom. This mode is no different from 51 and AVR, and is suitable for naked applications. Nor flash memory can be accessed in byte granularity like RAM, so the program in Nor flash memory is executed as if in RAM, and you can also choose to move the program to real RAM and execute it.

2) The figure on the right is the boot memory map of Nand flash memory, which is suitable for booting large programs with operating systems. The access to Nand flash memory is similar to the hard disk on a computer. It is a block device and the boot method is similar. First, the boot program at the beginning of the Nand flash memory is moved to the static memory (SRAM) inside the ARM. The role of the boot program is to load the larger boot program into the real RAM and then jump to it for execution.

 

II. Create and write a streaking program.

1) When creating, select s3c2440 as the cpu, and let MDK automatically generate the *.s startup code. There is a great document on the Internet about porting a bare-bones program from ADS without using the MDK startup code. There are many things to modify, but I just want a bare-bones program that lights up the LED. With my experience with 51 and AVR, I intuitively think that it should not require very complicated configuration.

2) *.s files can be configured visually in MDK, which is more user-friendly.

 

 The main configuration is the size of the RAM memory. My TQ2440 is 64M. There is also the port where the LED is connected. The following figure is the circuit diagram of the core board:

 

You can see the Led is connected to the GPB port.

3) Writing the main program. This is relatively simple.

 

III. Target option configuration (Project->Option for Target)

Target, Linker, Debug, and Utilities need to be configured. I started the configuration according to Nand, and you can figure out the configuration for Nor yourself.


Note: After trying, I found that in fact, only one DebugInRAM_config.ini configuration file is needed to run the program. The important part is SetupForStart(). The PC value should be set at the beginning of RAM. My PC value is 0x30000000 at the beginning of BANK6. It seems that J-link directly loads the program to the beginning of the external memory. This may be related to the configuration of Init(). If you want to debug, you must fill in all the information.

Reference address:Getting started with AVR MCU + using keil-MDK to run TQ2440

Previous article:AVR MCU fuse settings and detailed rescue methods
Next article:The growth path of single-chip microcomputer (avr basics) - 003 BOOT area of ​​AVR single-chip microcomputer

Recommended ReadingLatest update time:2024-11-16 13:47

How to solve the problem that printf() function cannot be used in STM32 (MDK)
Simply put: if you want to use printf in mdk, you need to redefine the fputc function and avoid using semihosting (semihosting mode). The default output device of the standard library function is the display. To achieve output on the serial port or LCD, you must redefine the functions called in the standard library fu
[Microcontroller]
How to solve the problem that printf() function cannot be used in STM32 (MDK)
STM32 study notes: the production and application of Keil project Lib library files
I recently looked at the Baidu bracelet open source project and found that all the algorithms were encapsulated into a lib file. This is the first time I have learned to call it in Keil. The question arises: Why should it be made into a lib library? 1. In order to keep the key source code written by some solution co
[Microcontroller]
STM32 study notes: the production and application of Keil project Lib library files
Keil (MDK-ARM) introduction, download, installation and registration
1 Overview MDK: Microcontroller Developer Kit microcontroller development tool. Keil MDK-ARM is an IDE (Integrated Development Environment) that supports ARM microcontrollers and is produced by the American software company Keil (now acquired by ARM). MDK-ARM includes industrial standard Keil C compiler, macro assembl
[Microcontroller]
Keil (MDK-ARM) introduction, download, installation and registration
LPC11XX using keil for arm and j-link connection problem
, J-link connection problem.  Lpc1114 uses SW connection. Change the port to SW. You cannot use the jatg method to link. Otherwise, the following problems will occur   2. After using the SW method, you need to modify   3. Check all or uncheck all.
[Microcontroller]
LPC11XX using keil for arm and j-link connection problem
STM32 MDK project creation diagram steps self-study summary
I haven't used MDK to write STM32 programs for a long time. Now I find that I can't remember the creation steps. So I read the book again and recorded it step by step-----refer to the example of Wildfire! ---Step 1---Create a folder---Create the following folders under the folder--- ---1-1---CMSIS is used to store t
[Microcontroller]
STM32 MDK project creation diagram steps self-study summary
ADS project transplantation keil5 project based on SmartARM2300 development board
Description of Requirement: I am currently working on a project using LCP2378 and need to use the CAN interface on this chip. The official examples are for the ADS platform. Based on my personal habits, I want to develop under Keil, so I need to convert the source code to the Keil platform and build the Keil5 software
[Microcontroller]
ADS project transplantation keil5 project based on SmartARM2300 development board
About PC-lint and how to add PC-lint tool in MDK
    Someone asked: What does /*lint !e750... */ mean in the code?     To answer this question, we need to involve the PC-Lint tool mentioned in this article. 1Written in front Those of you who have some programming experience may have seen "comments" like /*lint !e750... */ in some places. But how many peop
[Microcontroller]
About PC-lint and how to add PC-lint tool in MDK
How to view the memory contents in Keil's 51 microcontroller simulation debugging
       In Keil, friends who have played with 51 know that when debugging, the compiler provides a register window (Register), an interrupt system window (Interrupt System), an I/O port viewing window (I/O ports), a serial port and a timer setting window (serial, Timer). But how to view the contents of a certain memory
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号