#7 Arrays and Pointer Arithmetic

preview_player
Показать описание
Embedded Systems Programming Lesson-7 introduces you to arrays and basic pointer arithmetic in C. You will learn how to apply these concepts to take advantage of the more advanced features of the Stellaris GPIO DATA registers, which answers some questions asked in the comments to this video course posted on YouTube.

The lesson starts with explaining why the traditional read-modify-write sequence that you used in the previous lessons can be problematic when you add interrupts in the future.

Next, you see how this problem can be solved in hardware by using the address bits as a mask for updating the GPIO DATA bits. You get an understanding that this solution
requires many GPIO DATA registers, and you find out why the DATA register with the offset 0x3FC is so special.

Next, you try to use a brute-force solution from lesson-3 to synthesize the GPIO DATA register addresses manually and you verify that it works, although is not very elegant.

Next, you learn about arrays in C and their equivalence with pointers.

Next, you see how to index into an array and you learn about the equivalence between array indexing and pointer arithmetic.

Next, you verify the equivalence of the three approaches: address arithmetic, pointer arithmetic, and array indexing when it comes to the generated machine code.

You learn about the difference between address arithmetic and pointer arithmetic.

Finally, you learn about the two peripheral buses: APB and AHB in the LM4F microcontroller and you see how to switch the code to use the faster AHB.

The next lesson will be devoted to functions in C. Stay tuned...

------
Resources:

Companion web page for this video course:

GitHub repository for projects for this video course:

YouTube playlist of the course:
Рекомендации по теме
Комментарии
Автор

These videos are pure gold. I have yet to find something remotely as useful for properly learning embedded coding. Thank you Miro!

ctywi
Автор

Very well done. The pace of progression through subject material is just right, and the topics have been chosen intelligently. And the instructor knows his stuff and possesses the rare ability to explain it clearly and succinctly. Looking forward to the upcoming lessons and I hope the appear soon. I'm subscribed!

ljgmdad
Автор

I have been coding embedded systems for a year without these basic knowledge. I always wonder how the libraries address the register finally i got to know how.Thank you so much for taking this initiative you are the best.

suman
Автор

Yes, absolutely, more lessons are coming up.

I don't have an official syllabus, but my goal is to get as quickly as possible to interrupts, context switching, RTOS, and other such typically embedded subjects.

But before I get there, I need to talk about functions for at least two lessons. And then, I probably need a lesson about the startup code, because this is how interrupt service routines (ISRs) are hooked up on Cortex-M.

Anyway, the next lesson about functions is "in the works".

StateMachineCOM
Автор

The STM32 Discovery board is also an excellent choice for learning embedded programming and ARM Cortex-M microcontrollers in particular.

StateMachineCOM
Автор

Miro, these tutorials are simply excellent. Well done and thank you for creating them. Cant wait for your future uploads. I have C experience but am new to microcontrollers. I've been following your examples on a Teensy 3.0 and using Linux, and it has taught me SO much! I love the fact that you analyse the arm instructions. Perfect!

neostack
Автор

I recently got hired by a company for a mixed programming position. I had NO experience in embedded systems programming whatsoever and was struggling to catch up. This course single-handedly brought me up to speed with quality and clarity unrivaled by any other YouTube training course (and I have watched quite a few). If you have just found this course, keep going. You have come to the right place. The fact that Miro Samek has posted this course for free is the height of scholastic generosity. I have learned more from this course than any computer-science college class.

sandpaper-egg-
Автор

Arduino is by design a "rapid prototyping" platform. You can quickly build something that works and you are shielded from the complexities of the microcontroller.

But Arduino (including the DUE board) is not a good platform for this type of course, because it does not provide the hardware debugger. In other words, you cannot "see" inside the microcontroller, you cannot single-step through the machine code, you cannot play with the registers, etc.

StateMachineCOM
Автор

Great to show a concrete reason (interrupts) for atomic RMWs. This MCU (its GPIO) implements bit-banding in quite an interesting way. Many MCUs simply map each bit in the bit-band region to a word in the alias region, w/o enumerating all possible bit-combinations.

Thank you so much for introducing the AHB, the SYSCTL register to enable the AHB for GPIO, and the AHB aperture.

leohuang
Автор

This is a challenging and interesting lesson! after all not every course is a passive learning kind!

yashesvi-raina
Автор

Thank you very much for such a great video! I finally understand the use of registers in setting the GPIO that I want.

minhduyto
Автор

Miro, I really appreciate your efforts! Your lessons are very useful.
I have been following all your lessons, but I programmed into a Freescale FRDM-KL25Z (Cortex M0+)... I had to play with it a little, but everything what you teached are working so. Thanks a lot, I am looking forward the next lessons, especially interrupts...
thanks

blackandrew
Автор

Wonderful course! The unique feature of these lectures is that the machine code is discussed in detail. The information provided in the lessons is very useful. I look forward to the next ones!
By the way, what do you think about STM32 microcontrolers and the Discovery board?

SergejsNazarovs
Автор

All I can say is holy sh*t this series is so good. I’m definitely going to buy your book!

zDoubleE
Автор

I appreciate your efforts sir, these videos help me so much to understand embedded systems. I started my career with the aid of your videos and I am really grateful.

aliitastan
Автор

Finally I understand the basic concepts about memory usage, At least sometimes :).

KananDethin
Автор

it is really great to see the WORLDS DEFINITIONS OF COMPUTER, with real PRACTICAL MEANINGS, THAT HUMANS CAN really BUT NO BODAY HAS DONE THIS


I am not a COMPUTER GUY BUT i am enjoying it every

ahsanbaig
Автор

Lesson 8 has been published last night.
Enjoy!

StateMachineCOM
Автор

very nice !!! Thank you so much !! Best on youtube !

AliNormukhamedov
Автор

The Freedom board is very nice and I'm glad to hear that you can also use it for this course. The generic ARM code should work almost identically, although Cortex-M0+ has a smaller instruction set than Cortex-M4F. Obviously, the code specific to the peripherals won't work and needs to be adapted.
--Miro

StateMachineCOM