320 likes | 606 Views
Figure 9.1. A block diagram of a microwave oven. Figure 9.2. A simplified block diagram of a digital camera. Please see “ portrait orientation ” PowerPoint file for Chapter 7. Figure 9.6. Parallel interface registers. Figure 9.7. Receive and transmit structure of the serial interface.
E N D
Please see “portrait orientation” PowerPoint file for Chapter 7 Figure 9.6. Parallel interface registers.
Figure 9.7. Receive and transmit structure of the serial interface.
RBUF EQU $FFFFFFE0 Receiv e buffer. SST A T EQU $FFFFFFE2 Status register for serial in terface. P A OUT EQU $FFFFFFF1 P ort A output data. P ADIR EQU $FFFFFFF2 P ort A direction register. * Initialization ORIGIN $1000 Mo v eByte #$FF,P ADIR Configure P ort A as output. * T ransfer the c haracters LOOP T estbit #0,SST A T Chec k if new c haracter is ready . Branc h=0 LOOP Mo v eByte RBUF,P A OUT T ransfer a c haracter to P ort A. Branc h LOOP Figure 9.10. A generic assembly language program for character transfer using polling.
/* Define register addresses */ #define RBUF (v olatile c har *) 0xFFFFFFE0 #define SST A T (v olatile c har *) 0xFFFFFFE2 #define P A OUT (c har *) 0xFFFFFFF1 #define P ADIR (c har *) 0xFFFFFFF2 v oid main() { /* Initialize the parallel p ort */ *P ADIR = 0xFF; /* Configure P ort A as output */ /* T ransfer the c haracters */ while (1) { /* Infinite lo op */ while ((*SST A T & 0x1) = = 0); /* W ait for a new c haracter */ *P A OUT = *RBUF; /* Mo v e the c haracter to P ort A */ } } Figure 9.11. C program for character transfer using polling.
/* Define register addresses */ v olatile c har *RBUF = (c har *) 0xFFFFFFE0; v olatile c har *SST A T = (c har *) 0xFFFFFFE2; c har *P A OUT = (c har *) 0xFFFFFFF1; c har *P ADIR = (c har *) 0xFFFFFFF2; v oid main() { /* Initialize the parallel p ort */ *P ADIR = 0xFF; /* Configure P ort A as output */ /* T ransfer the c haracters */ while (1) { /* Infinite lo op */ while ((*SST A T & 0x1) = = 0); /* W ait for a new c haracter */ *P A OUT = *RBUF; /* Mo v e the c haracter to P ort A */ } } Figure 9.12. An alternative C program for character transfer using polling.
Mo v e P ADIR,R0 Mo v eByte #$FF,(R0) LOOP Mo v e SST A T,R0 T estbit #0,(R0) Branc h=0 LOOP Mo v e RBUF,R0 Mo v e P A OUT,R1 Mo v e (R0),(R1) Branc h LOOP Figure 9.13. Possible compiled code for the program segment in Figure 9.12.
RBUF EQU $FFFFFFE0 Receiv e buffer. SCONT EQU $FFFFFFE3 Con trol register for serial in terface. P A OUT EQU $FFFFFFF1 P ort A output data. P ADIR EQU $FFFFFFF2 P ort A direction register. * Initialization ORIGIN $1000 Mo v eByte #$FF,P ADIR Configure P ort A as output. Mo v e #INTSER V,$24 Set the in terrupt v ector. Mo v e #$40,PSR Pro cessor resp onds to IR Q in terrupts. Mo v eByte #$10,SCONT Enable receiv er in terrupts. * T ransfer lo op LOOP Branc h LOOP Infinite w ait lo op. * In terrupt service routine INTSER V Mo v eByte RBUF,P A OUT T ransfer a c haracter to P ort A. ReturnI Return from in terrupt. Figure 9.14. A generic assembly language program for character transfer using interrupts.
#define RBU (v olatile c har *) 0xFFFFFFE0 #define P A OUT (c har *) 0xFFFFFFF1 . . . v oid main() { . . . } v oid in tserv() { *P A OUT = *RBUF; /* Mo v e a c haracter to P ort A */ } Figure 9.15. A function call in a C program.
Please see “portrait orientation” PowerPoint file for Chapter 7 Figure 9.16. C program for character transfer using interrupts.
Please see “portrait orientation” PowerPoint file for Chapter 7 Figure 9.17. C program for transfer through a circular buffer.
Please see “portrait orientation” PowerPoint file for Chapter 7 Figure 9.18. A generic assembly language program for transfer through a circular buffer.
Please see “portrait orientation” PowerPoint file for Chapter 7 Page 1 of Figure 9.20. C program for the reaction timer.
Please see “portrait orientation” PowerPoint file for Chapter 7 Page 2 of Figure 9.20. C program for the reaction timer.
Please see “portrait orientation” PowerPoint file for Chapter 7 Page 1 of Figure 9.21. Assembly language program for the reaction timer using polling.
Please see “portrait orientation” PowerPoint file for Chapter 7 Page 2 of Figure 9.21. Assembly language program for the reaction timer using polling.