aditya.adi2293
Newbie level 1
- Joined
- Feb 12, 2013
- Messages
- 1
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,287
Hi....
I am trying to control an led matrix(5X7) using an 74HC595 latch+shift registers and atmega32.
I checked out several codes on the internet..it was quite easy.
So i tried making up my own code using atmel studio. But the output pins show zero output whatever serial data i send.
(The multimeter showed zero volts with GND as reference)
I tried it on 6 different ic's, all giving same result.
Here is the code:
- - - Updated - - -
Here is the code with meaning of each assignment
I am trying to control an led matrix(5X7) using an 74HC595 latch+shift registers and atmega32.
I checked out several codes on the internet..it was quite easy.
So i tried making up my own code using atmel studio. But the output pins show zero output whatever serial data i send.
(The multimeter showed zero volts with GND as reference)
I tried it on 6 different ic's, all giving same result.
Here is the code:
Code:
#include <avr/io.h>
#include <util/delay.h>
// PORTB used
// PINB7 = DataSerial
// PINB6 = REGCLK
// PINB5 = STORECLK
// PINB4 = MasterReset'
// PINB3 = OutoutEnable'
void send_high(void)
{
//I know delay of 1 ms is not needed..but is sufficient for my purpose
PORTB|=(1<<PINB7);
_delay_ms(1);
PORTB|=(1<<PINB6);
_delay_ms(1);
PORTB&=~(1<<PINB6);
_delay_ms(1);
PORTB&=~(1<<PINB7);
_delay_ms(1);
}
void send_low(void)
{
_delay_ms(1);
PORTB|=(1<<PINB6);
_delay_ms(1);
PORTB&=~(1<<PINB6);
_delay_ms(1);
}
void send_data(uint8_t data)
{
_delay_ms(1);
for(uint8_t var1=0;var1<8;++var1)
{ data=data<<var1;
if( data & 0x80 )
{ send_high();}
else
{ send_low();}
}
_delay_ms(1); //is it needed ?
PORTB|=(1<<PINB5);
_delay_ms(1);
PORTB&=~(1<<PINB5);
}
void main()
{
DDRB=0xFF;
PORTB=0x00;
_delay_ms(1);
PORTB|=(1<<PIND4);
_delay_ms(1);
PORTB|=(1<<PIND5);
_delay_ms(1);
PORTB&=~(1<<PIND5);
_delay_ms(1);
send_data(0xFF);
while(1)
{
}
}
- - - Updated - - -
Here is the code with meaning of each assignment
Code:
#include <avr/io.h>
#include <util/delay.h>
// PORTB
// The pin config :
//
// PINB7 = serial data
// PINB6 = shift clk
// PINB5 = store clk
// PINB4 = master reset'
// PINB3 = output enable'
void send_high(void)
{
PORTB|=(1<<PINB7); //data pin high
_delay_ms(1);
PORTB|=(1<<PINB6); //shift clk high
_delay_ms(1);
PORTB&=~(1<<PINB6); //shift clk low
_delay_ms(1);
PORTB&=~(1<<PINB7); //data clk low
_delay_ms(1);
}
void send_low(void)
{
_delay_ms(1);
PORTB|=(1<<PINB6); //shift clk high
_delay_ms(1);
PORTB&=~(1<<PINB6); //shift clk low
_delay_ms(1);
}
void send_data(uint8_t data)
{
_delay_ms(1);
for(uint8_t var1=0;var1<8;++var1)
{ data=data<<var1;
if( data & 0x80 )
{ send_high();}
else
{ send_low();}
}
_delay_ms(1);
PORTB|=(1<<PINB5); //store clk high
_delay_ms(1);
PORTB&=~(1<<PINB5); //store clk low
}
void main()
{
DDRB=0xFF;
PORTB=0x00; //reset register high
_delay_ms(1);
PORTB|=(1<<PIND4); //reset register low
_delay_ms(1);
PORTB|=(1<<PIND5); //store clk high
_delay_ms(1);
PORTB&=~(1<<PIND5); //store clk low
_delay_ms(1);
send_data(0xFF);
while(1)
{
}
}