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:
| RU(3..2) ---> RA(4..3) | RU(3..2) ---> RD(5..4) | |
| RT(3..2) ---> RC(7..6) | RT(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) | |
| RT(3..0) ---> RD(3..0) | Error ---> RD4 | S ---> RE1 |
| RU(3..2) ---> RA(1..0) | RU(1..0) ---> RD(7..6) |
Pin assignment option #3:
| AT(3..2) ---> RB(7..6) | AT(1..0) ---> RC(7..6) | OP ---> RA1 |
| RT(3..2) ---> RB(5..4) | RT(1..0) ---> RC(5..4) | |
| RU(3..2) ---> RE(1..0) | RU(3..2) ---> RA(3..2) | |
| 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) | |
| BT(3..0) ---> RD(7..4) | Error ---> RD3 | S ---> RE2 |