ECE 493T9 Real Time Embedded System Tutorial Set 1 May 12

Download Report

Transcript ECE 493T9 Real Time Embedded System Tutorial Set 1 May 12

ECE 493T9
Real Time Embedded System
Tutorial Set 2
May 26, Spring 2008
Here is your TA
• Scott Chen
• Office Hour: Monday 4:00pm to 5:00pm
@ EIT 3136
• Contact:
[email protected]
• Assignment: UW-ACE Drop Box (Hardcopy)
End of Tutorial (Softcopy)
Getting Started on New ES
• Tools in your hand:
1) ES Dev Kit / Custom-Assembled ES
2) Microcontroller User Manual
3) IDE Manual
4) ANSI-C Reference Handbook
5) Google Code Search
6)
Your Design Idea
• How do you put these pieces together with
your programming skills to realize your
design?
ES Software Design Procedure
1)
2)
3)
Identify the feature of your design.
Construct an abstract, conceptual block diagram, and convert all the
blocks into logical ones.
Identify the functionalities provided by your microcontroller that are
suitable for each of your logic blocks.
!! What if your microcontroller does not provide the
functionalities you need?
Source external ICs that not only can provide the needed functions,
but also have a compatible interface with your microcontroller.
ES Software Design Procedure
Continue…
4) Find out the method of initializing all the design-required modules on
the microcontroller.
5) Find out the proper ways to interact with the external ICs with your
microcontroller.
Above 2 steps gives you the Initialization
Routine. (In C and / or Assembly)
6) Convert each of your logic block into procedural threads /
subroutines, and combine them into RTOS or your own Assembly or
C main routine. ==
Programming Complete
Why and When do you need UM?
Starting step 2, you should have the following things ALWAYS sitting
on your workbench:
a) Your microcontroller user manual
b) Data sheet of all the external ICs you need
c) Instruction manual
d) ANSI-C Referenece Handbook
e) Customized C IDE manual
You need a) and b) in order to understand the entire hardware
platform you have, thereby enabling you to program with c), d), and
e).
What does a UM provide you?
• uC standard and specialized features.
• uC pin layout and chip package diagram.
• uC voltage standards.
- I/O standards for all the pins.
- uC power rating.
• Reset conditions, power-saving modes, uC’s initial state upon
power-up, etc...
• uC core data register set.
- Can be very different among uC families.
- in PIC18F2 family, only W.
- in Motorola HC1x family, A, B, X, Y
- What is the only core register that is common in all standard
uCs? (Technically 2.)
What does a UM provide you?
• On-chip module introduction
- Sync. and async. channels.
- Timers
- Specialized modules
- You need this section to perform step 3) in the ES software
design procedure.
• Memory Map
- Directly related to your linker script.
- Knowing the capability of your uC in memory management.
- Very different among uC families.
What does a UM provide you?
• Control / Functional Register Sets
- Beside core data registers, all other registers intended for
module control and uC funtion selection are assigned with
distinct address, with which you can read and/or write values
from/to the registers via regular memory access in C and ASM.
-
3 Types:
1) Read Only:
2) Write Only:
3) Read & Write:
UART Rx Register
UART Tx Register
Timer Configuration Register
-
You need to go through all the control register sets for your uC
and properly initialize them in order to configure your uC to in
the way you want. (It’s a Serious Mine Zone!!)
-
Possibly the most important part of the UM besides IM.
Instruction Manual
• The IM often comes as one large chapter in the UM.
• You may know ASM very well, but it doesn’t free you from reading
IM for a new uC. (Sucks, I know.)
• Things that are different in IMs of different uC families:
–
–
–
–
Available Core Register Sets (from UM)
Available Addressing Modes
Available Instruction Sets
Notation Conventions
• uC functionalities are directly proportional to its size and is closely
related to its intended purpose.
Ex: You will not find instructions for sophisticated mathematical
operations in a simple communication microcontroller.
Instruction Manual
• Common Addressing Modes:
–
–
–
–
Inheritant
Direct
Indexed
Indexed Indirect
• Not every uC has Indexed Indirect addressing mode.
• uCs with larger structures may have more advanced addressing
modes for application-specific purposes.
Ex: Zilog eZ80 family has a specialized extended 16-bit addressing
mode, enabling the 8-bit processor to manage a larger memory map.
Instruction Manual
• Every uC family has distinct architecture, thus the number of cycle
counts for two different uCs to perform the same instruction would
differ. (Sometimes very significantly!)
• Every uC manufacturer develops its own ASM notation to remain
“monopolistic competitive” (Just like the existence of DVD+R and
DVD-R). It gives them the edge for making large profit, while
leaving you system engineers to suffer longer learning curves.
• Conclusion: No matter how proficient you are in ASM programming,
you cannot escape from re-learning every uC you
come across throughout your engineering career.
The bright side is that, once you have mastered the uC
family, you get to fully exploit the functionalities it offers,
leading to more efficient product designs as well as a
higher salary level. =)
What’s Next?
• We Want a New Tutorial Time!!!
1) Mon 9:30am to 10:20am @ DWE 3517
2) Wed 9:30am to 10:20am @ DWE 3517
3) Additional session available upon
arrangement for those who cannot show
up for these two time slots.
What’s Next?
• Assembly Programming
• Since everyone in the class has proficient experience in ASM and C,
we will not cover any basics of ASM. (It will bore both you and me
out anyways. =p)
• Instead, we will go through some special cases where ASM
programming significantly outperforms C programming.
• We might also cover a bit on CRC check on-the-fly in both hardware
and software designs.
Questions?
Questions?
Questions?