Program w BASCOM-ie działa poprawnie tzn. gasi wszystkie punkty na graficznym LCD natomiast na moje oko taki sam program w C++ nie działa.
ATMEGA8 @ 1MHz
Co może być przyczyną ?
Jakie są różnice ?
BASCOM
C++
Z góry dziękuję za odpowiedź !
lukego
ATMEGA8 @ 1MHz
Co może być przyczyną ?
Jakie są różnice ?
BASCOM
Config Pinc.0 = Output
Config Pinc.1 = Output
Config Pinc.0 = Output
Config Pinc.1 = Output
Config Pinc.2 = Output
Config Pinc.3 = Output
Config Pinc.4 = Output
Config Pinc.5 = Output
Config Pinb.0 = Output
Config Pinb.1 = Output
Config Pinb.2 = Output
Config Pinb.3 = Output
Config Pinb.4 = Output
Config Pinb.5 = Output
Config Pinb.6 = Output
Config Pinb.7 = Output
Dim C As Byte
Dim P As Byte
Declare Sub Clock
Declare Sub Potw
Do
Reset Portc.0
Set Portc.1
Reset Portc.2
Reset Portc.4
Reset Portc.5
Portb = 175
Call Potw
Reset Portc.0
Reset Portc.1
Set Portc.2
Reset Portc.4
Reset Portc.5
Portb = 175
Call Potw
Reset Portc.1
Reset Portc.2
Reset Portc.0
Reset Portc.5
Portb = 193
Call Potw
Call Clock
For C = 0 To 70
For P = 1 To 4
Call Clock
Reset Portc.0
Reset Portc.5
Portb = 183 + P
Call Potw
Call Clock
Reset Portc.0
Reset Portc.5
Portb = C
Call Potw
Call Clock
Set Portc.0
Reset Portc.5
Portb = 0
Call Potw
Call Clock
Next P
Next C
Loop
Sub Clock
Set Portc.3
Waitus 250
Reset Portc.3
Waitus 250
End Sub
Sub Potw
Waitus 1
Set Portc.4
Waitus 1
Reset Portc.4
Waitus 1
End Sub
C++
#include <avr\io.h>
#include <avr\delay.h>
#include <inttypes.h>
void Potw()
{
_delay_us(1);
PORTC |= (1<<4);
_delay_us(1);
PORTC &= !(1<<4);
_delay_us(1);
}
void Clock()
{
PORTC |= (1<<3);
_delay_us(250);
PORTC &= !(1<<3);
_delay_us(250);
}
void setStartLine()
{
PORTC &= !(1<<1);
PORTC &= !(1<<2);
PORTC &= !(1<<PC0);
PORTC &= !(1<<5);
PORTB = 193;
Potw();
Clock();
}
void setPage (unsigned char p)
{
PORTC &= !(1<<PC0);
PORTC &= !(1<<5);
PORTB = 183+p;
Potw();
Clock();
}
void setCol(unsigned char c)
{
PORTC &= !(1<<PC0);
PORTC &= !(1<<5);
PORTB = c;
Potw();
Clock();
}
void writeData(unsigned char d)
{
PORTC |= (1<<PC0);
PORTC &= !(1<<5);
PORTB = d;
Potw();
Clock();
}
int main (void)
{
DDRB = 0xFF;
DDRC = 0xFF;
while(1)
{
PORTC &= !(1<<0);
PORTC |= (1<<1);
PORTC &= !(1<<2);
PORTC &= !(1<<4);
PORTC &= !(1<<5);
PORTB = 175; //DISPLAY ON
Potw();
PORTC &= !(1<<0);
PORTC &= !(1<<1);
PORTC |= (1<<2);
PORTC &= !(1<<4);
PORTC &= !(1<<5);
PORTB = 175; //DISPLAY ON
Potw();
PORTC &= !(1<<1);
PORTC &= !(1<<2);
PORTC &= !(1<<0);
PORTC &= !(1<<5);
PORTB = 193;
Potw();
Clock();
setStartLine();
for(unsigned char p = 1; p <= 4; p++)
for(unsigned char c = 1; c <= 70; c++)
{
setPage(p);
setCol(c);
writeData(0);
Clock();
}
}
return 0;
}
Z góry dziękuję za odpowiedź !
lukego