In an embedded system a microprocessor is used to control parts of a system, and this may involve sending and receiving logic signals via a parallel port. The MCF5206 parallel ports are explained in detail in the documentation; however, the registers for controlling Port A are as follows:
Register | Address | |
MBARx | 0x1000 0000 | module base address |
PADDR | MBARx + 0x01C5 | Port A data dir. reg., 8 bit, r/w |
PADAT | MBARx +0x01C9 | Port A data reg., 8 bit, r/w |
Read: DDR=0, write DDR=1
Let's look at an example of how to use Port A for TTL logic i/o. Download the assembly program porta1s.s:
/* porta1s.s test of port a parallel i/o */ .text .even .global main main: move.b #0xff,%d1 /* set port A */ move.b %d1,PADDR /* for output */ move.b #0b10101011,%d1 move.b %d1,PADAT /* write something to port A*/ rts MBARx = 0x10000000 /* Module Base Address value */ PADDR = MBARx+0x01C5 /* Port A Data Direction Register, ;8-bit, R/W */ PADAT = MBARx+0x01C9 /* Port A Data Register, 8-bit, R/W */
Examine this code carefully, and notice:
Exercise.
go 10000
A C version is available in the file
/* porta1c.c test of sbc port a */ #define MBARx 0x10000000 /* Module Base Address value */ #define PADDR (* (char *) (MBARx+0x01C5)) /* Port A Data Direction Register, ;8-bit, R/W */ #define PADAT (* (char *) (MBARx+0x01C9)) /* Port A Data Register, 8-bit, R/W */ int main() { PADDR = 0xff; /* set port A for output */ PADAT = 0xaa; /* output something */ return 0; }
ANU Engineering - ENGN3213