Playing with STM8 microcontroller (Part 1)

Publisher:SerendipitySoulLatest update time:2020-01-18 Source: eefocusKeywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

It is a very normal step-by-step learning method to learn the entire computer system from the microcontroller. Because until today, the computer system has not escaped this most basic architecture. Unfortunately, I skipped this process and started directly from Intel 486. At that time, I was struggling forward with countless questions every day.

You don't have to learn 51 microcontrollers. In fact, any one you choose is the same. From a practical point of view, you should choose a cheap one with fewer peripheral devices and more functions, so I chose STM8L for you.


STM8L is an 8-bit microcontroller. I did see some friends in the forum asking what is 8-bit? I am at least glad that this brother is really thinking about it. Usually, when I say 8-bit, I mean the ability of the CPU to calculate, or more specifically, to add, two 8-bit binary numbers. Similarly, 32-bit means the addition of 32-bit binary numbers.


In addition, and this is the most difficult part, the address range of this 8-bit microcontroller is not necessarily 8 bits, so you should pay attention to this. Address range, don't understand? It's better to say address range. Imagine that there are 8 address lines, and each line uses high or low voltage to represent 1 and 0. Then how many numbers can these 8 lines represent in total? You can count them one by one, of course, it is best to calculate 2 to the 8th power combinations. That is 256 numbers, each number represents an address to access one byte of data, so you can only access 256 bytes. This space is too small. So STMicroelectronics will not design it this way, so increase the address lines to 16 address lines, 2 to the 16th power, equals 65536 addresses. I remember a course called "Computer Principles", which is a very practical book, but unfortunately the teacher's teaching is too bad and unattractive.


65536 is 64KB. For STM8L151K4T6, 16KB flash and 2KB ram are enough for addressing. The entire address space of a microcontroller is usually very simple, which is a continuous linear space 0x0000~0xFFFF. It's just that there are pieces of memory scattered in it, some are flash, some are ram, some are register sets, and some are ROM. That's all, don't think it's complicated.

Flash and Ram are used to store code and data, including the stack.


Registers are the only interface for software to control peripherals. Writing a driver program is dealing with these registers. The design of registers for each chip is different, and you need to read a lot of information from the manufacturer, usually in English.


Fortunately, ST has released standard peripheral library functions, so you no longer need to care about register details. But if you are a MCU beginner, I recommend reading the standard peripheral library code and the chip manual. After you read a certain amount, you will find the commonalities of all chips on the market and understand the advantages and disadvantages of their designs. If you have a clear idea in mind, you can guess the register design of any chip without even reading the manual. This is the highest level of driver program.

Keywords:MCU Reference address:Playing with STM8 microcontroller (Part 1)

Previous article:STM8L minimum system board transplanted Atomthreads successfully
Next article:Playing with STM8 microcontroller (Part 2)

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号