Hello guys,i am new so, can anyone tell me where i have wrong?.I have a keyboard (PS2) connected to an 16f877a and nokia 3310 display.This circuit is working, when i type a letter is displayed on the display.The problem is when i change the microcontroller to 18f4550, it doesn't happend anything.
To make the code more simple i made some changes.
This is the code:
This code works on pic16f877a with 10 mhz oscilator
I have no ideea what i should change to make this work on pif18f4550 (10 mhz) or pic18f2520(16 mhz).
ps: the project is recompiled with this new settings the new microcontroller and new oscilator.
I will be happy if anyone have an ideea...many Thanks
To make the code more simple i made some changes.
This is the code:
I'm using pickit 2 clone, and microC pro for pic from MicroElectronika to write the code and compile.// LCD module connections
sbit sce at RB7_bit;
sbit res at RB6_bit;
sbit dc1 at RB5_bit;
sbit sdin at RB4_bit;
sbit sclk at RB3_bit;
sbit sce_Direction at TRISB7_bit;
sbit res_Direction at TRISB6_bit;
sbit dc1_Direction at TRISB5_bit;
sbit sdin_Direction at TRISB4_bit;
sbit sclk_Direction at TRISB3_bit;
// End LCD module connections
void clockdata(char bits_in)
{
int bitcnt;
for (bitcnt=8; bitcnt>0; bitcnt--)
{
sclk = 0; //Set Clock Idle level LOW.
if ((bits_in&0x80)==0x80) {sdin=1;} // PCD8544 clocks in theMSb first.
else {sdin=0;}
sclk = 1; //Data is clocked on the rising edge of SCK.
bits_in=bits_in<<1; // Logicalshift data by 1 bit left.
}
}
void writecom(char command_in)
{
dc1 = 0; // Select Command register.
sce = 0; // Select Chip.
clockdata(command_in); // Clock in command bits.
sce = 1; // Deselect Chip.
}
void LCD_set_XY(unsigned char X, unsigned char Y)
{
writecom(0x40|(Y&0x07)); // Y axis
writecom(0x80|(X&0x7f)); // X axis
}
void writedata(unsigned char data_in)
{
dc1 = 1; // Select Data register.
sce = 0; // Select Chip.
clockdata(data_in); // Clock in data bits.
sce = 1; // Deselect Chip.
}
void clearram(void)
{
int ddram;
LCD_set_XY(0,0);
// Cursor Home.
for (ddram=504;ddram>0;ddram--) {writedata(0x00);} // 6*84 = 504 DDRAMaddresses.
}
void LCD_innit()
{
res = 1; // Set _RES HIGH.
sce = 1; // Disable Chip.
res = 0; // Reset the LCD.
Delay_ms(100); // Wait 100ms.
res = 1; // Awake LCD from RESET state.
writecom(0x21); // Activate Chip and H=1.
writecom(0xC2); // Set LCD Voltage to about 7V.
writecom(0x13); // Adjust voltage bias.
writecom(0x20); // Horizontal addressing and H=0.
writecom(0x09); // Activate all segments.
clearram(); // Erase all pixel on the DDRAM.
writecom(0x08); // Blank the Display.
writecom(0x0C); // Display Normal.
LCD_set_XY(0,0); // Cursor Home.
}
void main() {
char *string = "a";
TRISB = 0; // Init PS/2 Keyboard
// gnd = 0;
// vol = 1;
LCD_innit();
LCD_set_XY(0,0);
writedata(0xaf);
}
This code works on pic16f877a with 10 mhz oscilator
I have no ideea what i should change to make this work on pif18f4550 (10 mhz) or pic18f2520(16 mhz).
ps: the project is recompiled with this new settings the new microcontroller and new oscilator.
I will be happy if anyone have an ideea...many Thanks
Last edited: