diff --git a/2ano/2semestre/ac2/aula04/AC2-P-Aula04.pdf b/2ano/2semestre/ac2/aula04/AC2-P-Aula04.pdf new file mode 100644 index 0000000..fb6e5c2 Binary files /dev/null and b/2ano/2semestre/ac2/aula04/AC2-P-Aula04.pdf differ diff --git a/2ano/2semestre/ac2/aula04/part1-1.c b/2ano/2semestre/ac2/aula04/part1-1.c new file mode 100644 index 0000000..bdba858 --- /dev/null +++ b/2ano/2semestre/ac2/aula04/part1-1.c @@ -0,0 +1,23 @@ +#include + +void delay(int ms) { + resetCoreTimer(); + while (readCoreTimer() < ms * 20000); +} + +int main() { + // Configure RB14 as output + TRISCbits.TRISC14 = 0; + + while (1) { + // Wait 0.5s + delay(500); + // Update value + LATCbits.LATC14 = !LATCbits.LATC14; + + // Print current value + printStr("RB14: "); + printInt10(LATCbits.LATC14); + putChar('\r'); + } +} diff --git a/2ano/2semestre/ac2/aula04/part1-2.c b/2ano/2semestre/ac2/aula04/part1-2.c new file mode 100644 index 0000000..d0adb19 --- /dev/null +++ b/2ano/2semestre/ac2/aula04/part1-2.c @@ -0,0 +1,22 @@ +#include + +void delay(int ms) { + resetCoreTimer(); + while (readCoreTimer() < ms * 20000); +} + +int main() { + // Configure RE6-RE3 as output + TRISE = TRISE & 0xFF87; + // Initialize the counter + unsigned int counter = 0; + + while (1) { + // Update value + LATE = (LATE & 0xFF87) // Reset bits 6-3 + | counter << 3; // Merge with counter + + delay(460); + counter = (counter + 1) % 10; + } +} diff --git a/2ano/2semestre/ac2/aula04/part1-3.c b/2ano/2semestre/ac2/aula04/part1-3.c new file mode 100644 index 0000000..983f017 --- /dev/null +++ b/2ano/2semestre/ac2/aula04/part1-3.c @@ -0,0 +1,22 @@ +#include + +void delay(int ms) { + resetCoreTimer(); + while (readCoreTimer() < ms * 20000); +} + +int main() { + // Configure RE6-RE3 as output + TRISE = TRISE & 0xFF87; + // Initialize the counter + unsigned int counter = 0; + + while (1) { + // Update value + LATE = (LATE & 0xFF87) // Reset bits 6-3 + | counter << 3; // Merge with counter + + delay(370); + counter = (counter + 9) % 10; + } +}