[AC2] Aula04 Part1
Signed-off-by: TiagoRG <tiago.rgarcia@ua.pt>
This commit is contained in:
parent
684fec032b
commit
8f742f3322
Binary file not shown.
|
@ -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');
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue