serial 7segment LED display module

serial 7 segment display test board, 16f1503 serial 7segment display, 16f54 serial 7segment display, 16f54

 

 

 

 

3-wire serial bus:

CLK, DAT synchronous

RESET – each time before loading serial data, the display is reset. The controller takes 20 mSec. to startup.

After the data has been clocked in, the display starts displaying. Hexadecimal values are possible, 6 bits for each digits.

To activate the point, 0x20 must be added to the digit value.

The source code shown here works at 8 MHz. There are delay constants both for serial data transmission, and for startup.

These values can be decreased, however there should be some margin. It is also possible to test for transitions on one of the Andode/Cathode pins- simply, if the display does not start displaying, then the transmission was not successful (too fast for instance).

The 3 digit modules use common Anode 7seg modules, the 4 digit modules use common Cathode modules. Indeed, the displays can be assembled using any 7segment display, or even a small LED matrix.

With 12 pins, for instance 5×7 is possible.

The RESET line must be hold at HIGH when using the display. The CLK and DAT lines must be released immediately, as they are multiplexed with the 7seg module.

A PIC 16f1503 is used for testing the serial display.

16f1503_ser_display – download complete project source here


#include <xc.h> /* XC8 General Include File */
#include “system.h” /* System funct/params, like osc/peripheral config */
#include “user.h” /* User funct/params, such as InitApp */
#define clk LATCbits.LATC1
#define dat LATCbits.LATC0
#define reset LATCbits.LATC2
#define delay 45
#define startup_delay 6000
unsigned char v_leds,v_key0,v_key1,v_mode;
unsigned char v_hold0,v_hold1,v_hold2;
unsigned char v_res0,v_res1,v_res2,v_res3;
unsigned int tmr0,v_point,v_bright;
unsigned int led0;
unsigned char key_tst(unsigned char k)
{
if(k==0){if(!(v_leds&0x04))k++; return(k);}
if(k==1){if(v_leds&0x04)k++; return(k);}
}
void send_ser(unsigned char ser_dat)
{unsigned char i;
if(ser_dat&0x01)dat=1; else dat=0;
clk=1;i=delay;while(i–);clk=0;
if(ser_dat&0x02)dat=1; else dat=0;
clk=1;i=delay;while(i–);clk=0;
if(ser_dat&0x04)dat=1; else dat=0;
clk=1;i=delay;while(i–);clk=0;
if(ser_dat&0x08)dat=1; else dat=0;
clk=1;i=delay;while(i–);clk=0;
if(ser_dat&0x10)dat=1; else dat=0;
clk=1;i=delay;while(i–);clk=0;
if(ser_dat&0x20)dat=1; else dat=0;
clk=1;i=delay;while(i–);clk=0;
}
void init_ser()
{unsigned int i;
clk=0;
dat=0;
reset=0;
i=delay;
while(i–);
reset=1;
i=startup_delay;while(i–);
}
void interrupt isr(void)
{unsigned char i;
if(TMR0IF)
{
TMR0IF=0; /* Clear Interrupt Flag 1 */
tmr0++;
// blink the LED with a short pulse
led0++;
}
if(led0==0x50)
{
if(v_leds&0x01)v_leds&=0xfe;else v_leds|=0x01;
}
if(led0==0x55)
{
if(v_leds&0x01)v_leds&=0xfe;
led0=0;
}
/*
v_leds&=0xfb;
if(PORTAbits.RA3)v_leds|=0x04;
v_key0=key_tst(v_key0);
v_leds&=0xfb;
if(PORTCbits.RC4)v_leds|=0x04;
v_key1=key_tst(v_key1);
if(v_key1==2)
{
v_key1=0;
}
if(v_key0==2)
{
v_key0=0;
v_bright++;
if(v_bright==0x10)v_bright=0;
//v_mode++;if(v_mode==3)v_mode=0;
}
*/
if(tmr0>100)
{
LATC=0;
LATA=0;
TRISA=0b11111100;
TRISC=0b11111000;
tmr0=0;
init_ser();
send_ser(0x1);
send_ser(0x2);
// send_ser(1);
send_ser(0x3);
send_ser(0x4);
// send_ser(v_res3);
TRISA=0xfe;
TRISC=0b11111011;
}
/*
ADCON1=0xf0;
if(v_mode==0)ADCON0=0b00011100;
if(v_mode==1)ADCON0=0b00011000;
if(v_mode==2)ADCON0=0b00010000;
ADON=1;
ADCON0bits.ADGO=1;
while(!ADIF);
ADIF=0;
if((v_mode==0)||(v_mode==1)||(v_mode==2))
{
v_res0=ADRESL&0xf;
v_res1=ADRESL>>4;
v_res2=ADRESH&0xf;
v_res3=v_mode;
}
if(v_mode==3)
{
v_res0=v_hold0;
v_res1=v_hold1;
v_res2=v_hold2;
v_res3=v_mode;
}
v_point++;if(v_point==4)v_point=0;
if(v_point==0)v_res0|=0x20;
if(v_point==1)v_res1|=0x20;
if(v_point==2)v_res2|=0x20;
if(v_point==3)v_res3|=0x20;
*/
}
void main(void)
{
InitApp();
OSCCONbits.IRCF=0xe;
v_mode=0;
v_key0=0;
v_point=0;
v_bright=0;
GIE=1;
TMR0IE=1;
OPTION_REGbits.nWPUEN=1;
while(1)
{
if(v_leds&0x01)PORTAbits.RA0=1;else PORTAbits.RA0=0;
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *

*