|
|||||
Chapter 3 problems |
- B3.17 - |
2-digit BCD adder / subtractor (μC - C) |
|||
|
1. Specifications
Design a 2-digit adder-subtractor for unsigned BCD numbers (Add_Subt_BCD_2digit) using a PIC18F46K22. We limit the circuit to 2-digit because the limited number of microcontroller pins.
![]() |
Fig. 1. Symbol and some truth table values. |
The same project is proposed in D1.17 as a combinational circuit based on logic gates.
Pin assignment option #1:
R(3..2) ---> RC(7..6) | R(1..0) ---> RB(7..6) | OP ---> RA5 |
BT(3..2) ---> RC(5..4) | BT(1..0) ---> RB(5..4) | |
AU(3..2) ---> RB(3..2) | AU(1..0) ---> RC(3..2) | Cout ---> RA1 |
BU(3..2) ---> RB(1..0) | BU(3..2) ---> RC(1..0) | |
AT(3..0) ---> RD(3..0) | Error ---> RD7 | S ---> RE1 |
Pin assignment option #2:
AT(3..2) ---> RC(7..6) | AT(1..0) ---> RB(7..6) | OP ---> RA2 |
BT(3..2) ---> RB(5..4) | BT(1..0) ---> RC(5..4) | |
AU(3..2) ---> RC(3..2) | AU(1..0) ---> RB(3..2) | Cout ---> RA5 |
BU(3..2) ---> RC(1..0) | BU(3..2) ---> RB(1..0) | |
R(3..0) ---> RD(3..0) | Error ---> RD4 | S ---> R21 |
Pin assignment option #3:
AT(3..2) ---> RB(7..6) | AT(1..0) ---> RC(7..6) | OP ---> RA1 |
R(3..2) ---> RB(5..4) | R(1..0) ---> RC(5..4) | |
AU(3..2) ---> RC(3..2) | AU(1..0) ---> RB(3..2) | Cout ---> RA5 |
BU(3..2) ---> RC(1..0) | BU(3..2) ---> RB(1..0) | |
B(3..0) ---> RD(7..4) | Error ---> RD3 | S ---> RE21 |