From 3cd7d84df5fefd82c9f60d92f1e29626cf9b3555 Mon Sep 17 00:00:00 2001 From: TiagoRG Date: Mon, 18 Mar 2024 21:33:00 +0000 Subject: [PATCH] [AC2] Aula04 Signed-off-by: TiagoRG --- 2ano/2semestre/ac2/aula04/part2-6.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 2ano/2semestre/ac2/aula04/part2-6.c diff --git a/2ano/2semestre/ac2/aula04/part2-6.c b/2ano/2semestre/ac2/aula04/part2-6.c new file mode 100644 index 0000000..2bc2c90 --- /dev/null +++ b/2ano/2semestre/ac2/aula04/part2-6.c @@ -0,0 +1,25 @@ +#include + +const unsigned int dis7Scodes[] = {0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, + 0xFD, 0x07, 0x7F, 0x6F, 0x77, 0xFC, + 0x39, 0x5E, 0xF9, 0xF1}; + +void delay(unsigned int ms) { + resetCoreTimer(); + while (readCoreTimer() < 20000 * ms); +} + +int main() { + TRISB &= 0x80FF; + TRISB |= 0x000F; + TRISD &= 0xFF9F; + + LATD = (LATD & 0xFF9F) | 0x0040; + + while (1) { + char c = PORTB & 0x000F; + LATB = (LATB & 0x80FF) | dis7Scodes[c] << 8; + } + + return 0; +}