[Help] ATmega16/32 for 64x8 Running Text with 74HC595

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

excuse me :wink:

well, i had a problem with my code in codevision AVR to display the running text works.

I built the running text with my own, and I had finished to display the character but I couldn't ran it till now :(

This is the code of mine to running the text of Dot Matrix 64x8 :o

/****************************************************
Chip type           : ATmega32
Program type        : Application
Clock frequency     : 12,000000 MHz
Memory model        : Small
External RAM size   : 0
Data Stack size     : 256
****************************************************/
#include 
#include 
#include 
#include 
#define latch PORTA.0
#define dta PORTA.1
#define clock PORTA.2
#define eo PORTA.3
// Alphanumeric LCD Module functions
//#asm
//   .equ __lcd_port=0x18 ;PORTB
//#endasm
//#include 
#include 
typedef unsigned char uc;
unsigned char hit=0;    unsigned char w=0;
unsigned char pos=0x01;
unsigned char buf[8]={0xFF,0xFF,0xFF,0xFF1,0xFF1,0xFF,0xFF,0xFF};
//unsigned char buf[8]={0xFC,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};

 void send_data();

void geser();
//void geser2();
//void kopi();
void teks();

interrupt [TIM1_OVF] void timer1_ovf_isr(void)
{
// Reinitialize Timer 1 value
TCNT1H=0xF4;
TCNT1L=0x48;

               if(w>80) {
                teks();
                w=0;
               }
               
               buf[0]=huruf[hit];
               buf[1]=huruf[hit+8];
            
                  if(hit>7){
                 hit=0; }
                send_data();  
              
                PORTC=pos;
                 pos=((pos<<1)|(pos>>7));
                 hit++;
                 w++;
                              
}

void main(void)
{
uc dt;
PORTA=0xFF;
DDRA=0xFF;
PORTB=0xFF;
DDRB=0xFF;
PORTC=0xFF;
DDRC=0xFF;
PORTD=0xFF;
DDRD=0xFF;
// prescaler 8
// Crystal frequency 12Mhz
// Clock value: 1500,000 kHz
// Mode: Normal top=FFFFh

TCCR1A=0x00;
TCCR1B=0x02;
TCNT1H=0xF4;
TCNT1L=0x48;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x04;

ACSR=0x80;
SFIOR=0x00;

//#asm("sei");
// LCD module initialization
//lcd_init(16);

    PORTA.3=0;
//    kopi();

//PORTC=0b00001111;
while (1)
 
        {

//               teks();
//               send_data();


              if(w>100) 
              {
                teks();
                w=0;
               }
               
               buf[0]=huruf[hit];
               buf[1]=huruf[hit+8];
            
                  if(hit>7){
                 hit=0; }
                send_data();  
              
                PORTC=pos;
                 pos=((pos<<1)|(pos>>7));
                 hit++;
                 w++;
                               delay_ms(2);
         }
}


void geser(){
unsigned char b,c;
    for(b=0;b<8;b++){
    c=buf[b];
     c=((c<<1)|(c>>7));
     buf[b]=c;
    }
    }
    


void teks(){
 uc temp,cary,z;
 uc x,c;
 
 geser();
 c=buf[0];
 temp=c&0x01;
  if(temp==0x01){z=0x01;}
  else {z=0x00;}
  for(x=1;x<8;x++){
  temp=(buf[x] & 0x01);
   if(temp==0x01){buf[x-1]=buf[x-1] | 0x01;}
  else {cary=0x00; 
  buf[x-1]=buf[x-1] & 0xFE;}
  
  }
   if(z==0x01){buf[7]=buf[7] | 0x01;}
  else {
  buf[7]=buf[7] & 0xFE;}

}
 
 void send_data(){
     unsigned char i,tmp,a;
    
     clock = 0;
     dta   = 0;
     latch = 0;
    for(a=0;a<8;a++){     
                
         for (i=0; i<8; i++){
             tmp = (buf[a]& 0x80);
             if (tmp==0x80) {dta = 1;}
             else{  dta = 0;}
             clock = 1;
             delay_us(10);
             clock = 0;
             buf[a]=((buf[a]<<1)|(buf[a]>>7));
         }  
                  
      }
     latch = 1;
     latch = 0;
 }

The code just being the Dot Matrix (DM) 64x8 run. Please, help me to find the library and How can I include that library into my code to run the Display with library charater ??

I'll be thankful if master want to help me in this problem. I'll appreciate it :)

regards,
ArcticSoul

ArcticSoul
Industrial Electronic Engineering, College Student

Last Edited: Mon. Sep 14, 2009 - 07:36 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I had reference about this problem but It was not works till now. I had the AVR GCC code to display the Dot Matriks, but the Column Driver was not 74HC595, It's HEF4794. And I had known the difference :)

I had built the code to display 64x8 [running with charaters] with 74HC595

header library

// font.h
//
// Tablica czcionek 5x7 
// 
#include 
static const char PROGMEM  font5x8[] = {
0x00, 0x00, 0x00, 0x00, 0x00,// (spacja)
0x00, 0x00, 0x5F, 0x00, 0x00,// !
0x00, 0x07, 0x00, 0x07, 0x00,// "
0x14, 0x7F, 0x14, 0x7F, 0x14,// #
0x24, 0x2A, 0x7F, 0x2A, 0x12,// $
0x23, 0x13, 0x08, 0x64, 0x62,// %
0x36, 0x49, 0x55, 0x22, 0x50,// &
0x00, 0x05, 0x03, 0x00, 0x00,// '
0x00, 0x1C, 0x22, 0x41, 0x00,// (
0x00, 0x41, 0x22, 0x1C, 0x00,// )
0x08, 0x2A, 0x1C, 0x2A, 0x08,// *
0x08, 0x08, 0x3E, 0x08, 0x08,// +
0x00, 0x50, 0x30, 0x00, 0x00,// ,
0x08, 0x08, 0x08, 0x08, 0x08,// -
0x00, 0x30, 0x30, 0x00, 0x00,// .
0x20, 0x10, 0x08, 0x04, 0x02,// /
0x3E, 0x51, 0x49, 0x45, 0x3E,// 0
0x00, 0x42, 0x7F, 0x40, 0x00,// 1
0x42, 0x61, 0x51, 0x49, 0x46,// 2
0x21, 0x41, 0x45, 0x4B, 0x31,// 3
0x18, 0x14, 0x12, 0x7F, 0x10,// 4
0x27, 0x45, 0x45, 0x45, 0x39,// 5
0x3C, 0x4A, 0x49, 0x49, 0x30,// 6
0x01, 0x71, 0x09, 0x05, 0x03,// 7
0x36, 0x49, 0x49, 0x49, 0x36,// 8
0x06, 0x49, 0x49, 0x29, 0x1E,// 9
0x00, 0x36, 0x36, 0x00, 0x00,// :
0x00, 0x56, 0x36, 0x00, 0x00,// ;
0x00, 0x08, 0x14, 0x22, 0x41,// <
0x14, 0x14, 0x14, 0x14, 0x14,// =
0x41, 0x22, 0x14, 0x08, 0x00,// >
0x02, 0x01, 0x51, 0x09, 0x06,// ?
0x32, 0x49, 0x79, 0x41, 0x3E,// @
0x7E, 0x11, 0x11, 0x11, 0x7E,// A
0x7F, 0x49, 0x49, 0x49, 0x36,// B
0x3E, 0x41, 0x41, 0x41, 0x22,// C
0x7F, 0x41, 0x41, 0x22, 0x1C,// D
0x7F, 0x49, 0x49, 0x49, 0x41,// E
0x7F, 0x09, 0x09, 0x01, 0x01,// F
0x3E, 0x41, 0x41, 0x51, 0x32,// G
0x7F, 0x08, 0x08, 0x08, 0x7F,// H
0x00, 0x41, 0x7F, 0x41, 0x00,// I
0x20, 0x40, 0x41, 0x3F, 0x01,// J
0x7F, 0x08, 0x14, 0x22, 0x41,// K
0x7F, 0x40, 0x40, 0x40, 0x40,// L
0x7F, 0x02, 0x04, 0x02, 0x7F,// M
0x7F, 0x04, 0x08, 0x10, 0x7F,// N
0x3E, 0x41, 0x41, 0x41, 0x3E,// O
0x7F, 0x09, 0x09, 0x09, 0x06,// P
0x3E, 0x41, 0x51, 0x21, 0x5E,// Q
0x7F, 0x09, 0x19, 0x29, 0x46,// R
0x46, 0x49, 0x49, 0x49, 0x31,// S
0x01, 0x01, 0x7F, 0x01, 0x01,// T
0x3F, 0x40, 0x40, 0x40, 0x3F,// U
0x1F, 0x20, 0x40, 0x20, 0x1F,// V
0x7F, 0x20, 0x18, 0x20, 0x7F,// W
0x63, 0x14, 0x08, 0x14, 0x63,// X
0x03, 0x04, 0x78, 0x04, 0x03,// Y
0x61, 0x51, 0x49, 0x45, 0x43,// Z
0x00, 0x00, 0x7F, 0x41, 0x41,// [
0x02, 0x04, 0x08, 0x10, 0x20,// "\"
0x41, 0x41, 0x7F, 0x00, 0x00,// ]
0x04, 0x02, 0x01, 0x02, 0x04,// ^
0x40, 0x40, 0x40, 0x40, 0x40,// _
0x00, 0x01, 0x02, 0x04, 0x00,// `
0x20, 0x54, 0x54, 0x54, 0x78,// a
0x7F, 0x48, 0x44, 0x44, 0x38,// b
0x38, 0x44, 0x44, 0x44, 0x20,// c
0x38, 0x44, 0x44, 0x48, 0x7F,// d
0x38, 0x54, 0x54, 0x54, 0x18,// e
0x08, 0x7E, 0x09, 0x01, 0x02,// f
0x08, 0x14, 0x54, 0x54, 0x3C,// g
0x7F, 0x08, 0x04, 0x04, 0x78,// h
0x00, 0x44, 0x7D, 0x40, 0x00,// i
0x20, 0x40, 0x44, 0x3D, 0x00,// j
0x00, 0x7F, 0x10, 0x28, 0x44,// k
0x00, 0x41, 0x7F, 0x40, 0x00,// l
0x7C, 0x04, 0x18, 0x04, 0x78,// m
0x7C, 0x08, 0x04, 0x04, 0x78,// n
0x38, 0x44, 0x44, 0x44, 0x38,// o
0x7C, 0x14, 0x14, 0x14, 0x08,// p
0x08, 0x14, 0x14, 0x18, 0x7C,// q
0x7C, 0x08, 0x04, 0x04, 0x08,// r
0x48, 0x54, 0x54, 0x54, 0x20,// s
0x04, 0x3F, 0x44, 0x40, 0x20,// t
0x3C, 0x40, 0x40, 0x20, 0x7C,// u
0x1C, 0x20, 0x40, 0x20, 0x1C,// v
0x3C, 0x40, 0x30, 0x40, 0x3C,// w
0x44, 0x28, 0x10, 0x28, 0x44,// x
0x0C, 0x50, 0x50, 0x50, 0x3C,// y
0x44, 0x64, 0x54, 0x4C, 0x44,// z
0x00, 0x08, 0x36, 0x41, 0x00,// {
0x00, 0x00, 0x7F, 0x00, 0x00,// |
0x00, 0x41, 0x36, 0x08, 0x00,// }
0x08, 0x08, 0x2A, 0x1C, 0x08,// ->
0x08, 0x1C, 0x2A, 0x08, 0x08 // <-
};
//

:idea:

main program 64x8 with 74HC595

/**************************
* Application Information *
**************************/

/*
Device: AtMega32
Clock: External Crystal @ 12MHz
hfuse: 0xC9
lfuse: 0xEF

LED row controller on port C
LED shift registers on port A
12MHz crystal on Xtal1/Xtal2
*/


/*****************
* Hardware Setup *
*****************/

/*		____________________Mega32___________________
		
UDN2981-Pin1	|PC0 	
UDN2981-Pin2	|PC1 	(ADC3)	PA3| 74HC595-Pin15 (OE active low)
UDN2981-Pin3	|PC2 	(ADC2)	PA2| 74HC595-Pin3 (Clk)
UDN2981-Pin4	|PC3 	(ADC1)	PA1| 74HC595-Pin2 (Data)
UDN2981-Pin5	|PC4 	(ADC0)	PA0| 74HC595-Pin1 (Latch)
UDN2981-Pin6	|PC5
UDN2981-Pin7	|PC6
UDN2981-Pin8	|PC7
		
		--------------------------------------------
*/



#define F_CPU 12000000UL

#include 
#include 
#include 
#include 
#include "font5x8.h"

//The pins used to operate the shift register:
#define ShiftPort 	PORTA
#define ShiftDDR	DDRA
#define LatchPin	(1 << 0)
#define DataPin		(1 << 1)
#define ClkPin		(1 << 2)
#define OE		    (1 << 3)

#define TotColumns	64 // Dot Matrix 64x8

//The pins used to switch the row driver:
#define RowPort		PORTC
#define RowDDR		DDRC
#define RowPin0		(1 << 0)
#define RowPin1		(1 << 1)
#define RowPin2		(1 << 2)
#define RowPin3		(1 << 3)
#define RowPin4		(1 << 4)
#define RowPin5		(1 << 5)
#define RowPin6		(1 << 6)
#define RowPin7		(1 << 7)

#define ScrollSpeed	75	//How many milliseconds to pause before shifting columns left

typedef unsigned char u8;
typedef unsigned int u64;

u8 row_track = 0;

volatile u64 row_buffer[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };

static const char PROGMEM Messages1[] = { "64x8 LED Display Matrix" };
static const char PROGMEM Messages2[] = { "Politeknik Negeri Jakarta" };

void Delay_ms(int cnt)	//Function delays a give number of milliseconds.  Depends on F_CPU being defined
{
  while (cnt-->0) _delay_ms(1);
}

static inline void InitPorts(void)	//Function used once to initialize the ports
{
  ShiftDDR |= (LatchPin | ClkPin | DataPin | OE);	//Setup shift register control pins
  RowDDR |= (RowPin0 | RowPin1 | RowPin2 | RowPin3 | RowPin4 | RowPin5 | RowPin6 | RowPin7); //Setup row driver pins
  
  ShiftPort &= ~OE;
  RowPort |= RowPin0;				//Drive first row and enable shift registers

  ShiftPort |= LatchPin; 				//Set latch pin high
  ShiftPort &= ~(ClkPin | DataPin); 			//Set ClkPin and DataPin low
}

static inline void InitTimers(void)	//Function used once to set up the timer
{
  TCCR1B |= 1<<WGM12 | 1<<CS11 | 1<<CS10;		//Start timer1 in CTC mode with prescaler of 64
  TIMSK |= 1<<OCIE1A;					//Enable compare match interrupt
  OCR1A = 0x00BB;					//Set compare value for 1 mSec
  sei();						//Enable global interrupts
}

void Shift_Int(u64 shiftData)		//Function used to shift in data (Alter this when adding more than 8 columns)
{
  ShiftPort &= ~(LatchPin | ClkPin | DataPin);  	//All pins low: LatchPin low signals a write operation
  
  for (char TrackColumns=0; TrackColumns

well, I had downloaded this code but the matrix didn't display what I want [sometimes all Dot Glow, I think the system of the scanning display was error]

Will you want help me to solve this problem :)

ArcticSoul
Industrial Electronic Engineering, College Student

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

rotasidteach wrote:
excuse me :wink:

well, i had a problem with my code in codevision AVR to display the running text works.

I built the running text with my own, and I had finished to display the character but I couldn't ran it till now :(

This is the code of mine to running the text of Dot Matrix 64x8 :o

/****************************************************
Chip type           : ATmega32
Program type        : Application
Clock frequency     : 12,000000 MHz
Memory model        : Small
External RAM size   : 0
Data Stack size     : 256
****************************************************/
#include 
#include 
#include 
#include 
#define latch PORTA.0
#define dta PORTA.1
#define clock PORTA.2
#define eo PORTA.3
// Alphanumeric LCD Module functions
//#asm
//   .equ __lcd_port=0x18 ;PORTB
//#endasm
//#include 
#include 
typedef unsigned char uc;
unsigned char hit=0;    unsigned char w=0;
unsigned char pos=0x01;
unsigned char buf[8]={0xFF,0xFF,0xFF,0xFF1,0xFF1,0xFF,0xFF,0xFF};
//unsigned char buf[8]={0xFC,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};

 void send_data();

void geser();
//void geser2();
//void kopi();
void teks();

interrupt [TIM1_OVF] void timer1_ovf_isr(void)
{
// Reinitialize Timer 1 value
TCNT1H=0xF4;
TCNT1L=0x48;

               if(w>80) {
                teks();
                w=0;
               }
               
               buf[0]=huruf[hit];
               buf[1]=huruf[hit+8];
            
                  if(hit>7){
                 hit=0; }
                send_data();  
              
                PORTC=pos;
                 pos=((pos<<1)|(pos>>7));
                 hit++;
                 w++;
                              
}

void main(void)
{
uc dt;
PORTA=0xFF;
DDRA=0xFF;
PORTB=0xFF;
DDRB=0xFF;
PORTC=0xFF;
DDRC=0xFF;
PORTD=0xFF;
DDRD=0xFF;
// prescaler 8
// Crystal frequency 12Mhz
// Clock value: 1500,000 kHz
// Mode: Normal top=FFFFh

TCCR1A=0x00;
TCCR1B=0x02;
TCNT1H=0xF4;
TCNT1L=0x48;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x04;

ACSR=0x80;
SFIOR=0x00;

//#asm("sei");
// LCD module initialization
//lcd_init(16);

    PORTA.3=0;
//    kopi();

//PORTC=0b00001111;
while (1)
 
        {

//               teks();
//               send_data();


              if(w>100) 
              {
                teks();
                w=0;
               }
               
               buf[0]=huruf[hit];
               buf[1]=huruf[hit+8];
            
                  if(hit>7){
                 hit=0; }
                send_data();  
              
                PORTC=pos;
                 pos=((pos<<1)|(pos>>7));
                 hit++;
                 w++;
                               delay_ms(2);
         }
}


void geser(){
unsigned char b,c;
    for(b=0;b<8;b++){
    c=buf[b];
     c=((c<<1)|(c>>7));
     buf[b]=c;
    }
    }
    


void teks(){
 uc temp,cary,z;
 uc x,c;
 
 geser();
 c=buf[0];
 temp=c&0x01;
  if(temp==0x01){z=0x01;}
  else {z=0x00;}
  for(x=1;x<8;x++){
  temp=(buf[x] & 0x01);
   if(temp==0x01){buf[x-1]=buf[x-1] | 0x01;}
  else {cary=0x00; 
  buf[x-1]=buf[x-1] & 0xFE;}
  
  }
   if(z==0x01){buf[7]=buf[7] | 0x01;}
  else {
  buf[7]=buf[7] & 0xFE;}

}
 
 void send_data(){
     unsigned char i,tmp,a;
    
     clock = 0;
     dta   = 0;
     latch = 0;
    for(a=0;a<8;a++){     
                
         for (i=0; i<8; i++){
             tmp = (buf[a]& 0x80);
             if (tmp==0x80) {dta = 1;}
             else{  dta = 0;}
             clock = 1;
             delay_us(10);
             clock = 0;
             buf[a]=((buf[a]<<1)|(buf[a]>>7));
         }  
                  
      }
     latch = 1;
     latch = 0;
 }

The code just being the Dot Matrix (DM) 64x8 run. Please, help me to find the library and How can I include that library into my code to run the Display with library charater ??

I'll be thankful if master want to help me in this problem. I'll appreciate it :)

regards,
ArcticSoul

please help me find the code :(

ArcticSoul
Industrial Electronic Engineering, College Student

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

can anybody help me ?

ArcticSoul
Industrial Electronic Engineering, College Student

Last Edited: Tue. Sep 15, 2009 - 05:10 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As you don't seem to be getting much response I wonder if it's something to do with the way you are asking the question (no one is going to plough through reams of code)? Maybe this thread about "how to ask questions" will give you some ideas of how better to outline the problem you are trying to solve?

https://www.avrfreaks.net/index.p...

Cliff (moderator)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
As you don't seem to be getting much response I wonder if it's something to do with the way you are asking the question (no one is going to plough through reams of code)? Maybe this thread about "how to ask questions" will give you some ideas of how better to outline the problem you are trying to solve?

https://www.avrfreaks.net/index.p...

Cliff (moderator)

thanks for your response Cliff :)

i see..i just wanted to know how the running text works with the library in codevision AVR..i just knew about the concept about it in AVR GCC..

I'll go to that link :D

ArcticSoul
Industrial Electronic Engineering, College Student

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm going to assume that by "running text" you mean scrolling text. Scrolling text is a simple as outputting a line of text, delaying, and then re-outputting the line with a different start position. If you want to do the scrolling at the pixel level, you will need have your character functions start displaying the character at a given offset within the glyph.

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

glitch wrote:
I'm going to assume that by "running text" you mean scrolling text. Scrolling text is a simple as outputting a line of text, delaying, and then re-outputting the line with a different start position. If you want to do the scrolling at the pixel level, you will need have your character functions start displaying the character at a given offset within the glyph.

I want to make the program like LCD.
I set the character input like "hello" and so the dot matrix scrool the text "hello" too :)

ArcticSoul
Industrial Electronic Engineering, College Student