Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
uint8_t BCD;
LATBbits.LATB = (BCD & 0xFF)
while(1){
LATB=0; //ensure all off
LATB=digit1+0x80; //turn on digit 1
delay_ms(10);
LATB=0; //ensure all off
LATB=digit2+0x40; //turn on digit 2
delay_ms(10);
LATB=0; //ensure all off
LATB=digit3+0x20; //turn on digit 3
delay_ms(10);
LATB=0; //ensure all off
LATB=digit4+0x10; //turn on digit 4
delay_ms(10);
}
static void DisplayTemp(float ConvertDisplay)
{
int display;
uint8_t tenths;
uint8_t ones;
uint8_t tens;
uint8_t hundreds;
uint8_t BCD;
uint8_t value;
ConvertDisplay = ConvertDisplay * 10;
display = (int)ConvertDisplay;
tenths = display%10;
display /= 10;
ones = display%10;
display /= 10;
tens = display%10;
display /= 10;
hundreds = display;
if(!SysOpbits.Advance)
{
switch (Digits)
{
case hundred:
BCD = DecToBCD(hundreds);
Dig1_SetHigh(); //RB4
break;
case ten:
BCD = DecToBCD(tens);
Dig2_SetHigh(); //RB5
break;
case one:
BCD = DecToBCD(ones);
Dig3_SetHigh(); //RB6
break;
case tenth:
BCD = DecToBCD(tenths);
Dig3_SetHigh(); //RB6 for decimal point
Dig4_SetHigh(); //RB7
DP_SetLow(); //decimal point on
break;
}
}
LATBbits.LATB = (BCD & 0xFF);
}
If you need the digit 3's decimal point set then it needs to be in the one: section.
Mike.
switch (Digits)
{
case hundred:
BCD = DecToBCD(hundreds);
Dig1_SetHigh();
break;
case ten:
BCD = DecToBCD(tens);
Dig2_SetHigh();
break;
case one:
BCD = DecToBCD(ones);
Dig3_SetHigh();
DP_SetLow();
break;
case tenth:
BCD = DecToBCD(tenths);
Dig4_SetHigh();
break;
}
LATBbits.LATB |= BCD;
If you've got a 10mS interrupt then why not do the digits in that?
Mike.
void TMR2_ISR(void)
{
// clear the TMR2 interrupt flag
PIR1bits.TMR2IF = 0;
if (!SysOpbits.Advance)
{
if (Digits++ == tenth)
{
Digits = hundred;
}
BCD1_SetLow();
BCD2_SetLow();
BCD4_SetLow();
BCD8_SetLow();
Dig1_SetLow();
Dig2_SetLow();
Dig3_SetLow();
Dig4_SetLow();
DP_SetHigh();
}
if(TMR2_InterruptHandler)
{
TMR2_InterruptHandler();
}
}
This comment is about the way you're using current limiting resistors for the 7 segment display.
You have placed the resistors in the digit lines instead of the segment lines. This will cause the brightness of the digit to change depending on how many segments are lit in the digit. For example, when a one is displayed, the total current is shared by 2 segments. But when an eight is displayed, that same current is shared by 7 segments. So a one will be brighter than and eight.
It would be better to place the resistors in the segment lines.
if(TMR2_InterruptHandler)
{
TMR2_InterruptHandler();
}
It checks for a 'NULL' function pointer as a sanity check before executing the function pointer.I don't understand how this bit of code can work.
Code:if(TMR2_InterruptHandler) { TMR2_InterruptHandler(); }
void (*TMR2_InterruptHandler)(void);
void TMR2_SetInterruptHandler(void (* InterruptHandler)(void)){
TMR2_InterruptHandler = InterruptHandler;
}
I don't understand how this bit of code can work.
Code:if(TMR2_InterruptHandler) { TMR2_InterruptHandler(); }
Mike.
Mike - K8LH , I like those displays, played with some max7219 driven displays but 8 digits is normally too much. Four is perfect.
Edit, I note they have both the DP and the colon LEDs - are these all controllable?