codename25
Member level 3
- Joined
- Jan 15, 2015
- Messages
- 65
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 6
- Activity points
- 555
The problem I'm facing is my code is designed like the row is activated only after sending all the data to the shift register. Since the whole display is lengthy it takes much time for sending whole data to shift register which means at this time nothing is displayed.
I have already mentioned that the latch pin (output enable pin 13) is connected to low permanently which means latch is activated all the time. Since the row is activated only after sending the 120 bit data to the shift registers there is no significance for latch. But as you said, Chinese displays, simultaneously send data and displays the previous data, can be done only through latch. But in my case I should find another way.
If the time for sending one bit data to shift registers is 1ms then
It seems you are sending bit by bit with software. Don't do this.I think it has SPI but I don't know what is it and how to use it.
But how can pin 13 help my display flicker free. What is its purpose?
#define F_CPU 20000000UL
#include <avr/io.h>
#include <util/delay.h>
/***************************************
Configure Connections
****************************************/
#define HC595_PORT PORTB
#define HC595_DDR DDRB
#define HC595_DS_POS PB0 //Data pin (DS) pin location
#define HC595_SH_CP_POS PB1 //Shift Clock (SH_CP) pin location
#define HC595_ST_CP_POS PB2 //Store Clock (ST_CP) pin location
/***************************************
Configure Connections ***ENDS***
****************************************/
//Initialize HC595 System
void HC595Init()
{
//Make the Data(DS), Shift clock (SH_CP), Store Clock (ST_CP) lines output
HC595_DDR|=((1<<HC595_SH_CP_POS)|(1<<HC595_ST_CP_POS)|(1<<HC595_DS_POS));
}
//Low level macros to change data (DS)lines
#define HC595DataHigh() (HC595_PORT|=(1<<HC595_DS_POS))
#define HC595DataLow() (HC595_PORT&=(~(1<<HC595_DS_POS)))
//Sends a clock pulse on SH_CP line
void HC595Pulse()
{
//Pulse the Shift Clock
HC595_PORT|=(1<<HC595_SH_CP_POS);//HIGH
HC595_PORT&=(~(1<<HC595_SH_CP_POS));//LOW
}
//Sends a clock pulse on ST_CP line
void HC595Latch()
{
//Pulse the Store Clock
HC595_PORT|=(1<<HC595_ST_CP_POS);//HIGH
HC595_PORT&=(~(1<<HC595_ST_CP_POS));//LOW
}
/*
Main High level function to write a single byte to
Output shift register 74HC595.
Arguments:
single byte to write to the 74HC595 IC
Returns:
NONE
Description:
The byte is serially transfered to 74HC595
and then latched. The byte is then available on
output line Q0 to Q7 of the HC595 IC.
*/
void HC595Write(uint8_t data,int l)
{
//Send each 8 bits serially
//Order is MSB first
for(uint8_t i=0;i<l;i++)
{
//Output the data on DS line according to the
//Value of MSB
if(data & 0b10000000)
{
//MSB is 1 so output high
HC595DataHigh();
}
else
{
//MSB is 0 so output high
HC595DataLow();
}
HC595Pulse(); //Pulse the Clock line
data=data<<1; //Now bring next bit at MSB position
}
//Now all 8 bits have been transferred to shift register
//Move them to output latch at one
HC595Latch();
}
/*
Simple Delay function approx 0.5 seconds
*/
void delayfn(uint8_t loop)
{
if(loop<7){
PORTA=(1<<loop);
_delay_ms(0.2);
PORTA=(0<<loop); //Wait
}else{
PORTD=(1<<loop-7);
_delay_ms(0.2);
PORTD=(0<<loop-7);
}
}
int main()
{
uint8_t led_pattern_1[480]={
0b11000111,
0b11101111,
0b11101111,
0b11111111,
0b11111111,
0b11111111,
0b01111110,
0b01111110,
0b00111100,
0b00111100,
0b00011000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
/////
0b11000111,
0b11101111,
0b11101111,
0b11111111,
0b11111111,
0b11111111,
0b01111110,
0b01111110,
0b00111100,
0b00111100,
0b00011000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b11000111,
0b11101111,
0b11101111,
0b11111111,
0b11111111,
0b11111111,
0b01111110,
0b01111110,
0b00111100,
0b00111100,
0b00011000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b01111111,
0b01111111,
0b00011100,
0b00011100,
0b00011100,
0b00011100,
0b00011100,
0b00011100,
0b00011100,
0b00011100,
0b01111111,
0b01111111,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b01100000,
0b01100000,
0b01100000,
0b01100000,
0b01100000,
0b01100000,
0b01100000,
0b01100000,
0b01100000,
0b01100000,
0b01111111,
0b01111111,
0b00011100,
0b00111110,
0b01111111,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01111111,
0b00111110,
0b00011100,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b00110110,
0b00011100,
0b00001000,
0b01111111,
0b01111111,
0b01100000,
0b01100000,
0b01100000,
0b01111110,
0b01111110,
0b01100000,
0b01100000,
0b01100000,
0b01111111,
0b01111111,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b00111110,
0b00011100,
0b00011100,
0b00011100,
0b00011100,
0b00011100,
0b00011100,
0b00111110,
0b01111111,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01111111,
0b00111110,
0b00011100,
/////
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b00111110,
0b00011100,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b01100011,
0b01110111,
0b01110111,
0b01110111,
0b01111111,
0b01111111,
0b01111111,
0b01101011,
0b01101011,
0b01101011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b00111110,
0b00011100,
0b00011100,
0b00011100,
0b00011100,
0b00011100,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b01100000,
0b01100000,
0b01100000,
0b01100000,
0b01100000,
0b01100000,
0b01100000,
0b01100000,
0b01100000,
0b01100000,
0b01111111,
0b01111111,
0b00111110,
0b01111111,
0b01100011,
0b01100011,
0b01100011,
0b01111111,
0b01111111,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100001,
0b01100011,
0b01100110,
0b01101100,
0b01111000,
0b01110000,
0b01110000,
0b01111000,
0b01101100,
0b01100110,
0b01100011,
0b01100001,
0b00111110,
0b01111111,
0b01100011,
0b01100000,
0b01100000,
0b01111110,
0b00111111,
0b00000011,
0b00000011,
0b01100011,
0b01111111,
0b00111110,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01111111,
0b01111111,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01110111,
0b01110111,
0b01110111,
0b01111111,
0b01111111,
0b01111111,
0b01101011,
0b01101011,
0b01101011,
0b01100011,
0b01100011,
0b01111111,
0b01111111,
0b00011100,
0b00011100,
0b00011100,
0b00011100,
0b00011100,
0b00011100,
0b00011100,
0b00011100,
0b01111111,
0b01111111,
0b01100001,
0b01100011,
0b01100110,
0b01101100,
0b01111000,
0b01110000,
0b01110000,
0b01111000,
0b01101100,
0b01100110,
0b01100011,
0b01100001,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b00111110,
0b00011100,
0b01111111,
0b01111111,
0b00011100,
0b00011100,
0b00011100,
0b00011100,
0b00011100,
0b00011100,
0b00011100,
0b00011100,
0b00011100,
0b00011100,
0b01111111,
0b01111111,
0b00011100,
0b00011100,
0b00011100,
0b00011100,
0b00011100,
0b00011100,
0b00011100,
0b00011100,
0b00011100,
0b00011100,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b00111110,
0b00011100,
0b00011100,
0b00011100,
0b00011100,
0b00011100,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b11000111,
0b11101111,
0b11101111,
0b11111111,
0b11111111,
0b11111111,
0b01111110,
0b01111110,
0b00111100,
0b00111100,
0b00011000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b11000111,
0b11101111,
0b11101111,
0b11111111,
0b11111111,
0b11111111,
0b01111110,
0b01111110,
0b00111100,
0b00111100,
0b00011000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
/////
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b11000111,
0b11101111,
0b11101111,
0b11111111,
0b11111111,
0b11111111,
0b01111110,
0b01111110,
0b00111100,
0b00111100,
0b00011000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
/////
};
////////one time registration
uint8_t led_pattern_2[480]={
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b11000111,
0b11101111,
0b11101111,
0b11111111,
0b11111111,
0b11111111,
0b01111110,
0b01111110,
0b00111100,
0b00111100,
0b00011000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b11000111,
0b11101111,
0b11101111,
0b11111111,
0b11111111,
0b11111111,
0b01111110,
0b01111110,
0b00111100,
0b00111100,
0b00011000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b11000111,
0b11101111,
0b11101111,
0b11111111,
0b11111111,
0b11111111,
0b01111110,
0b01111110,
0b00111100,
0b00111100,
0b00011000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b00111110,
0b00011100,
0b00011100,
0b00011100,
0b00011100,
0b00011100,
0b00011100,
0b00111110,
0b01111111,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01111111,
0b00111110,
0b00011100,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b00111110,
0b00011100,
///K
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
////E
0b00111110,
0b01111111,
0b01100011,
0b01100011,
0b01100011,
0b01111111,
0b01111111,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
///R
0b01111100,
0b01111110,
0b01100011,
0b01100011,
0b01100011,
0b01111110,
0b01111100,
0b01111000,
0b01101100,
0b01100110,
0b01100011,
0b01100011,
//////A
0b01111111,
0b01111111,
0b01100000,
0b01100000,
0b01100000,
0b01111110,
0b01111110,
0b01100000,
0b01100000,
0b01100000,
0b01111111,
0b01111111,
///L
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
//////A
0b01100011,
0b01110111,
0b01110111,
0b01110111,
0b01111111,
0b01111111,
0b01111111,
0b01101011,
0b01101011,
0b01101011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b00111110,
0b00011100,
0b00011100,
0b00011100,
0b00011100,
0b00011100,
///P
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
///S
0b00111110,
0b01111111,
0b01100011,
0b01100000,
0b01100000,
0b01111110,
0b00111111,
0b00000011,
0b00000011,
0b01100011,
0b01111111,
0b00111110,
////C
0b00011100,
0b00111110,
0b01111111,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01111111,
0b00111110,
0b00011100,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b01100011,
0b00111110,
0b00011100,
///R
0b01100000,
0b01100000,
0b01100000,
0b01100000,
0b01100000,
0b01100000,
0b01100000,
0b01100000,
0b01100000,
0b01100000,
0b01111111,
0b01111111,
////E
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
/////G
0b11000111,
0b11101111,
0b11101111,
0b11111111,
0b11111111,
0b11111111,
0b01111110,
0b01111110,
0b00111100,
0b00111100,
0b00011000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
///S
0b11000111,
0b11101111,
0b11101111,
0b11111111,
0b11111111,
0b11111111,
0b01111110,
0b01111110,
0b00111100,
0b00111100,
0b00011000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
///R
0b11000111,
0b11101111,
0b11101111,
0b11111111,
0b11111111,
0b11111111,
0b01111110,
0b01111110,
0b00111100,
0b00111100,
0b00011000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
///T
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
///I
};
//////passport registration
uint8_t led_pattern_3[480]={
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
};
//////end of array
//Initialize HC595 system
HC595Init();
DDRA=0xFF;
PORTA=0;
DDRD=0xFF;
PORTD=0;
int speed;
speed=11; //speed of scroll increase to decrease speed
int array;
array=15; //no of matrix *****dontforget****
int l,j,m,n,p,s,count;
l=0;
m=0;
n=0;
s=0;
int height=12;// no of rows for us it is 12
int matrix=480;//no of array
matrix=matrix-(array*12);
int cartoonsteps=4;//cartoon frames
void refresh(){
for(uint8_t k=0;k<20;k++)///speed of the scroll
{
int loop=0; //for the scanning rows 1-12 1-12...
for(uint8_t i=0;i<12;i++)
{
for(uint8_t q=0;q<12;q++){
HC595Write(led_pattern_1[q],8);//this is for full 8 row data sending
}
delayfn(loop);
loop=loop+1;
}
}
}
while(1)
{
for(uint8_t k=0;k<speed;k++)///speed of the scroll
{
////*******cartoon starts here*****/////
int loop=0; //for the scanning rows 1-12 1-12...
for(uint8_t i=0;i<12;i++)
{
p=n;
for(uint8_t q=0;q<array;q++){
if(count==1){
HC595Write(led_pattern_2[i+p],8);//this is for full 8 row data sending
}else{
HC595Write(led_pattern_1[i+p],8);//this is for full 8 row data sending
}
p=p+12;
}
delayfn(loop);
loop=loop+1;
}
}
n=n+12;
if(n>matrix){n=0;int n1=0;refresh();if(count==1){count=0;}else{count=1;}}
//text 1 finish
//loop for entire cycle
////*******cartoon ends here*****/////
}
}
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?