|
Part 1ýConstructing the Platform
by Ed Sutter
Start ý The
Typical Package ý What are the Alternatives?
ý Key Ingredients ý MicroMonitor
Run Time Startup ý Just After Reset
ý Establish Exception Handlers ý I/O
Initialization ý Flash Memory Drivers
ý Sources and PDF
I/O INITIALIZATION
At this point, you have the basic initialization
completed and are at C level. The monitor has initialized memory and
stack, and it can access its periphery without having any kind of
bus error. Even if it did have a bus error, you would be able to handle
it through some exception handler. Now, make sure that all peripherals
are settled down, reset and disable all I/O, and initialize the UART.
(If you have anything to say about it during the hardware design,
try to make sure that the microprocessor has the ability to reset
each of its peripherals independently, without the need to power-cycle
or hard-reset the target. This comes in handy.) This should always
be the first device (after memory) to be configured so that you can
start to use printf() to report status to the user.
The UART functions provide a raw putchar(),
getchar(), and gotachar() for use throughout the monitor
code. Each function is written in Polled mode, and a hook is provided
within the function so that an alternate function can be called in
its place. This alternate function is typically a function that is
part of an operating system and is provided so that the monitor functions,
which call putchar(), getchar(), and gotachar(),
can still be used by an application that runs on top of the monitor
and has reinitialized the UART to run under its domain. An example
implementation for getchar() with the hook can be seen in Listing
3.
|
int
getchar(void)
{
extern int (*remotegetchar)();
if (remotegetchar)
return(remotegetchar);
/* code to retrieve
a character goes here */
}
|
| Listing 3ýHere
you can see the monitorýs getchar() with application-specific
override. |
By default the remotegetchar function
pointer is null, so the local code to retrieve a character would be
executed.
PREVIOUS
NEXT
Circuit Cellar provides up-to-date information for engineers. Visit
www.circuitcellar.com for
more information and additional articles.
For subscription information, call (860) 875-2199, subscribe@circuitcellar.com
or subscribe online.
ýCircuit Cellar, the Magazine for Computer Applications. Posted with
permission. |