Projects 8051 Binary Pattern on the Port 1
Projects 8051
Binary Pattern on the Port 1 LEDs ; This program displays the binary pattern ; from 0 to 255 (and back to 0) on the LEDs ; interfaced with port 1. ; A 1 in the pattern is represented by the LED on, ; while a 0 in the pattern is represented by the LED off. ; However, logic 0 on a port 1 pin turns on the LED, ; therefore it is necessary to write the inverse of the ; pattern to the LEDs. The easiest way to do this is ; to send the data FFH to 0 (and back to FFH) to the LEDs. ; Since port 1 is initially at FFH all we need to do is ; continuously decrement port 1. start: DEC P 1 ; decrement port 1 JMP start ; and repeat
Switches to the LEDs ; switches on P 2 to the LEDs on P 1. ; When a switch is closed a logic 0 appears ; on that P 2 pin, which is then copied to ; that P 1 bit which turns on that LED. ; Therefore, a closed switch is seen as a lit ; LED and vice versa. start: MOV P 1, P 2 ; move data on P 2 pins to P 1 JMP start ; and repeat
Multiplexing the 7 -segment Displays ; This program multiplexes the number 1234 ; on the four 7 -segment displays. ; Note: a logic 0 lights a display segment. start: SETB P 3. 3 ; | SETB P 3. 4 ; | enable display 3 MOV P 1, #11111001 B ; put pattern for 1 on display MOV P 1, #0 FFH ; clear the display CLR P 3. 3 ; enable display 2 MOV P 1, #10100100 B ; put pattern for 2 on display MOV P 1, #0 FFH ; clear the display CLR P 3. 4 ; | SETB P 3. 3 ; | enable display 1 MOV P 1, #10110000 B ; put pattern for 3 on display MOV P 1, #0 FFH ; clear the display CLR P 3. 3 ; enable display 0 MOV P 1, #1001 B ; put pattern for 4 on display MOV P 1, #0 FFH ; clear display JMP start ; jump back to start
Ramp Signal on the DAC Output ; This program generates a ramp on the DAC ; output. ; You can try adding values other than 8 ; to the accumulator to see what this does ; to the ramp signal. CLR P 0. 7 ; enable the DAC WR line loop: MOV A, #00 h MOV P 1, A ; move data in the accumulator to the DAC inputs (on P 1) ADD A, #8 ; increase accumulator by 8 JMP loop ; jump back to loop
- Slides: 6