[AC2] Aula04 Part1

Signed-off-by: TiagoRG <tiago.rgarcia@ua.pt>
This commit is contained in:
Tiago Garcia 2024-03-06 01:25:46 +00:00
parent 684fec032b
commit 8f742f3322
Signed by: TiagoRG
GPG Key ID: DFCD48E3F420DB42
4 changed files with 67 additions and 0 deletions

Binary file not shown.

View File

@ -0,0 +1,23 @@
#include <detpic32.h>
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');
}
}

View File

@ -0,0 +1,22 @@
#include <detpic32.h>
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;
}
}

View File

@ -0,0 +1,22 @@
#include <detpic32.h>
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;
}
}