Level: Rookie

Joined: Fri. Feb 8, 2019

Posted by zackdgod:
Fri. Feb 8, 2019 - 07:16 PM
I am using the following circuit with the given code. When running at low speed (500 ms) all columns are displayed individually perfectly. But when trying to use POV to combine them together, the row disappears. Not sure if this the correct place to post this question, but any help would be appreciated.

#include <mega8.h>
#include <delay.h>
#include <stdint.h>
#define sclock PORTB.1
#define slatch PORTB.2
#define sdata PORTB.0
uint8_t j,i=0,a[]={255, 255, 193, 247, 247, 193, 255, 255};
void dshift(uint8_t data)
{ uint8_t i=0;
for(i=0;i<8;i++)
{
if(data & 0b10000000)
{
sdata=1;
}
else
{
sdata=0;
}
sclock=1;sclock=0;
data=data<<1; //Now bring next bit at MSB position
}
slatch=1;slatch=0;
delay_us(5);
}
void main(void)
{
// Input/Output Ports initialization
// Port B initialization
// Function: Bit7=Out Bit6=Out Bit5=Out Bit4=Out Bit3=Out Bit2=Out Bit1=Out Bit0=Out
DDRB=(1<<DDB7) | (1<<DDB6) | (1<<DDB5) | (1<<DDB4) | (1<<DDB3) | (1<<DDB2) | (1<<DDB1) | (1<<DDB0);
// State: Bit7=0 Bit6=0 Bit5=0 Bit4=0 Bit3=0 Bit2=0 Bit1=0 Bit0=0
PORTB=(0<<PORTB7) | (0<<PORTB6) | (0<<PORTB5) | (0<<PORTB4) | (0<<PORTB3) | (0<<PORTB2) | (0<<PORTB1) | (0<<PORTB0);
// Port C initialization
// Function: Bit6=Out Bit5=Out Bit4=Out Bit3=Out Bit2=Out Bit1=Out Bit0=Out
DDRC=(1<<DDC6) | (1<<DDC5) | (1<<DDC4) | (1<<DDC3) | (1<<DDC2) | (1<<DDC1) | (1<<DDC0);
// State: Bit6=0 Bit5=0 Bit4=0 Bit3=0 Bit2=0 Bit1=0 Bit0=0
PORTC=(0<<PORTC6) | (0<<PORTC5) | (0<<PORTC4) | (0<<PORTC3) | (0<<PORTC2) | (0<<PORTC1) | (0<<PORTC0);
// Port D initialization
// Function: Bit7=Out Bit6=Out Bit5=Out Bit4=Out Bit3=Out Bit2=Out Bit1=Out Bit0=Out
DDRD=(1<<DDD7) | (1<<DDD6) | (1<<DDD5) | (1<<DDD4) | (1<<DDD3) | (1<<DDD2) | (1<<DDD1) | (1<<DDD0);
// State: Bit7=0 Bit6=0 Bit5=0 Bit4=0 Bit3=0 Bit2=0 Bit1=0 Bit0=0
PORTD=(0<<PORTD7) | (0<<PORTD6) | (0<<PORTD5) | (0<<PORTD4) | (0<<PORTD3) | (0<<PORTD2) | (0<<PORTD1) | (0<<PORTD0);
while (1)
{
dshift(a[0]);
for(i=0,j=1;i<8;i++)
{
delay_us(500);
dshift(a[(i+1)%8]);
PORTB.3=1;
PORTB.3=0;
}
}
}

This topic has a solution. Jump to the solution.

## Tags:

Last Edited: Sat. Feb 9, 2019 - 10:21 AM