Compare commits
2 Commits
356e7c9055
...
71975600d0
Author | SHA1 | Date |
---|---|---|
Tiago Garcia | 71975600d0 | |
Tiago Garcia | bd2206d705 |
|
@ -7,16 +7,14 @@ void delay(int ms) {
|
|||
|
||||
int main() {
|
||||
// Configure RE6-RE3 as output
|
||||
TRISE = TRISE & 0xFF87;
|
||||
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
|
||||
LATE = (LATE & 0xFF87) | counter++ << 3;
|
||||
counter %= 10;
|
||||
|
||||
delay(460);
|
||||
counter = (counter + 1) % 10;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,16 +7,14 @@ void delay(int ms) {
|
|||
|
||||
int main() {
|
||||
// Configure RE6-RE3 as output
|
||||
TRISE = TRISE & 0xFF87;
|
||||
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
|
||||
LATE = (LATE & 0xFF87) | counter << 3;
|
||||
counter = (counter + 9) % 10;
|
||||
|
||||
delay(370);
|
||||
counter = (counter + 9) % 10;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
#include <detpic32.h>
|
||||
|
||||
int main() {
|
||||
// Configure ports as output
|
||||
TRISB &= 0x80FF; // Use bits 14-8
|
||||
TRISD &= 0xFF9F; // Use bits 6-5
|
||||
|
||||
// Select only least significative display
|
||||
LATD = (LATD & 0xFF9F) | 0x0020;
|
||||
|
||||
while (1) LATB = LATB & 0x80FF | 0x0100 << (getChar() - 'a');
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
#include <detpic32.h>
|
||||
|
||||
void delay(unsigned int ms) {
|
||||
resetCoreTimer();
|
||||
while(readCoreTimer() < 20000 * ms);
|
||||
}
|
||||
|
||||
int main() {
|
||||
// Configure ports as output
|
||||
TRISB &= 0x80FF; // Use bits 14-8
|
||||
TRISD &= 0xFF9F; // Use bits 6-5
|
||||
|
||||
// Select least significative display
|
||||
LATD = (LATD & 0xFF9F) | 0x0020;
|
||||
|
||||
while (1) {
|
||||
unsigned char segment = 1;
|
||||
for (; segment < (1<<7); segment <<= 1) {
|
||||
LATB = (LATB & 0x80FF) | segment << 8;
|
||||
delay(500);
|
||||
}
|
||||
LATD ^= 0x0060;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
#include <detpic32.h>
|
||||
|
||||
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;
|
||||
TRISD &= 0xFF9F;
|
||||
LATD = (LATD & 0xFF9F) | 0x0020;
|
||||
|
||||
unsigned int n = 0;
|
||||
while (1) {
|
||||
LATB = (LATB & 0x80FF) | dis7Scodes[n++] << 8;
|
||||
n %= 16;
|
||||
delay(500);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,44 @@
|
|||
#include <detpic32.h>
|
||||
|
||||
const unsigned int dis7Scodes[] = {0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D,
|
||||
0xFD, 0x07, 0x7F, 0x6F, 0x77, 0xFC,
|
||||
0x39, 0x5E, 0xF9, 0xF1};
|
||||
|
||||
typedef enum { HIGH, LOW } flag;
|
||||
|
||||
void send2displays(unsigned char value) {
|
||||
static flag f = LOW;
|
||||
|
||||
if (f == HIGH) {
|
||||
LATD = (LATD & 0xFF9F) | 0x0040;
|
||||
LATB = (LATB & 0x80FF) | dis7Scodes[value >> 4] << 8;
|
||||
f = LOW;
|
||||
} else {
|
||||
LATD = (LATD & 0xFF9F) | 0x0020;
|
||||
LATB = (LATB & 0x80FF) | dis7Scodes[value & 0x0F] << 8;
|
||||
f = HIGH;
|
||||
}
|
||||
}
|
||||
|
||||
void delay(unsigned int ms) {
|
||||
resetCoreTimer();
|
||||
while (readCoreTimer() < ms * 20000);
|
||||
}
|
||||
|
||||
int main() {
|
||||
TRISB &= 0x80FF;
|
||||
TRISD &= 0xFF9F;
|
||||
|
||||
int counter = 0;
|
||||
|
||||
while (1) {
|
||||
int i = 0;
|
||||
do {
|
||||
send2displays(counter % 255);
|
||||
delay(10);
|
||||
} while (++i < 20);
|
||||
counter++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
#include <detpic32.h>
|
||||
|
||||
const unsigned int dis7Scodes[] = {0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D,
|
||||
0xFD, 0x07, 0x7F, 0x6F, 0x77, 0xFC,
|
||||
0x39, 0x5E, 0xF9, 0xF1};
|
||||
|
||||
typedef enum { HIGH, LOW } flag;
|
||||
|
||||
unsigned char toBdc(unsigned char value) {
|
||||
return ((value / 10) << 4) + (value % 10);
|
||||
}
|
||||
|
||||
void send2displays(unsigned char value) {
|
||||
static flag f = LOW;
|
||||
value = toBdc(value);
|
||||
unsigned char high = dis7Scodes[value >> 4];
|
||||
unsigned char low = dis7Scodes[value & 0x0F];
|
||||
|
||||
if (f == HIGH) {
|
||||
LATD = (LATD & 0xFF9F) | 0x0040;
|
||||
LATB = (LATB & 0x80FF) | high << 8;
|
||||
f = LOW;
|
||||
} else {
|
||||
LATD = (LATD & 0xFF9F) | 0x0020;
|
||||
LATB = (LATB & 0x80FF) | low << 8;
|
||||
f = HIGH;
|
||||
}
|
||||
}
|
||||
|
||||
void delay(unsigned int ms) {
|
||||
resetCoreTimer();
|
||||
while (readCoreTimer() < ms * 20000);
|
||||
}
|
||||
|
||||
int main() {
|
||||
TRISB = (TRISB & 0x80FF) | 0x0001;
|
||||
TRISD &= 0xFF9F;
|
||||
TRISC &= 0xBFFF;
|
||||
|
||||
int counter = 0;
|
||||
int toggler = 0;
|
||||
|
||||
while (1) {
|
||||
int i = 0;
|
||||
int sw0 = PORTB & 0x0001;
|
||||
do {
|
||||
send2displays(counter);
|
||||
delay(10);
|
||||
LATC &= 0xBFFF;
|
||||
if (toggler++ < 500) LATC |= 0x4000;
|
||||
} while (++i < (sw0 ? 20 : 50));
|
||||
counter += sw0 ? 1 : -1;
|
||||
if (counter < 0) {
|
||||
counter = 59;
|
||||
toggler = 0;
|
||||
}
|
||||
if (counter > 59) {
|
||||
counter = 0;
|
||||
toggler = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue