![]() | ![]() | ![]() |
| |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
![]() |
| | Tools |
| | #1 |
|
hi guys Hope evryone will b fine there, guys please tell what wrong with this my simple program of lcd void main() { TRISB=0; Lcd_Init(&PORTB); Lcd_Cmd(Lcd_CLEAR); Lcd_Out(1,1,"electronics"); } it is giving following error on build. 0 125 All files Preprocessed in 100 ms 0 121 Compilation Started lcd.c 5 313 Too many actual parameters lcd.c 6 324 Undeclared identifier 'Lcd_CLEAR' in expression lcd.c 0 102 Finished (with errors): 23 Jul 2009, 20:54:13 lcd.mcppi please telll what is wrong. | |
| |
| | #2 |
|
You missed a part the part in red Code: char *text = "electronics";
void main() {
TRISB = 0; // PORTB is output
Lcd_Init(&PORTB); // Initialize LCD connected to PORTB
Lcd_Cmd(Lcd_CLEAR); // Clear display
Lcd_Cmd(Lcd_CURSOR_OFF); // Turn cursor off
Lcd_Out(1, 1, text); // Print text to LCD, 2nd row, 1st column
}//~!
Last edited by be80be; 23rd July 2009 at 05:55 PM. | |
| |
| | #3 |
| I believe that is telling you that the constant Lcd_CLEAR is not recognised, I would try using LCD_CLEAR instead, or you can look in the file lcd.c and see how they defined it there..
| |
| |
| | #4 |
|
hi guys finally i got the right program for mikroc pro ver2.25 which is atleast building // Lcd pinout settings sbit LCD_RS at RB0_bit; sbit LCD_EN at RB1_bit; sbit LCD_D7 at RB7_bit; sbit LCD_D6 at RB6_bit; sbit LCD_D5 at RB5_bit; sbit LCD_D4 at RB4_bit; // Pin direction sbit LCD_RS_Direction at TRISB0_bit; sbit LCD_EN_Direction at TRISB1_bit; sbit LCD_D7_Direction at TRISB7_bit; sbit LCD_D6_Direction at TRISB6_bit; sbit LCD_D5_Direction at TRISB5_bit; sbit LCD_D4_Direction at TRISB4_bit; void main() { Lcd_Init(); TRISB = 0; // PORTB is output // Initialize LCD connected to PORTB Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Cmd(_LCD_CURSOR_OFF); // Turn cursor off Lcd_Out(1, 1, "electronics"); // Print text to LCD, 2nd row, 1st column }//~! but there is no result on lcd , lcd is only lightning i m using 50 K pot. please tell what gona wrong. | |
| |
| | #5 |
|
A 5 to 10k pot is all i every used what chip you using
| |
| |
| | #6 |
|
i use pic18f452 system with 4Mhz crystal , i also used 5k pot , dear please look on another program i made also not working // LCD module connections sbit LCD_RS at RD2_bit; sbit LCD_EN at RD3_bit; sbit LCD_D4 at RD4_bit; sbit LCD_D5 at RD5_bit; sbit LCD_D6 at RD6_bit; sbit LCD_D7 at RD7_bit; sbit LCD_RS_Direction at TRISD2_bit; sbit LCD_EN_Direction at TRISD3_bit; sbit LCD_D4_Direction at TRISD4_bit; sbit LCD_D5_Direction at TRISD5_bit; sbit LCD_D6_Direction at TRISD6_bit; sbit LCD_D7_Direction at TRISD7_bit; // End LCD module connections char txt1[] = "mikroElektronika"; char txt2[] = "BigPIC5"; char txt3[] = "Lcd4bit"; char txt4[] = "example"; char i; // Loop variable void Move_Delay() { // Function used for text moving Delay_ms(2000); // You can change the moving speed here } void main(){ ADCON1 |= 0x06; // Configure AN pins as digital Lcd_Init(); // Initialize LCD Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off Lcd_Out(1,6,txt3); // Write text in first row Lcd_Out(2,6,txt4); // Write text in second row Delay_ms(2000); Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Out(1,1,txt1); // Write text in first row Lcd_Out(2,5,txt2); // Write text in second row Delay_ms(2000); // Moving text for(i=0; i<4; i++) { // Move text to the right 4 times Lcd_Cmd(_LCD_SHIFT_RIGHT); Move_Delay(); } while(1) { // Endless loop for(i=0; i<7; i++) { // Move text to the left 7 times Lcd_Cmd(_LCD_SHIFT_LEFT); Move_Delay(); } for(i=0; i<7; i++) { // Move text to the right 7 times Lcd_Cmd(_LCD_SHIFT_RIGHT); Move_Delay(); } } } i dont think there is any comparator in pic18f452 system , b/s i hve seen some programs asking for turning off comparator. dear please solve this problem or send me any other working code , i atleast need to check my hardware. | |
| |
| | #7 |
|
There is no comparator in the 18F452
| |
| |
| | #8 |
|
einton try this out and see if you can get this going you have to gnd all unused pins like in the screen shot I zip the code you unzip it and run it
| |
| |
| | #9 |
|
thanx be80be thanx 4 ur code i could try it but i m working on mikroc pro , i initially try on mikroc but there was a problem of config bits in that ,so i left that, now using mikroc pro and atleast i know there is no problem of config bits , since i have tested. help on mikroc pro if possible.
| |
| |
| | #10 | |
|
It has the hex in the zip what programmer are you using and what do you mean Quote:
| ||
| |
| | #11 |
|
thanx be80be dear i have universal programmer which asks for writing config bits in its config bits window before programming chip, when using mikroc i copy bits from edit project ,but it didnt work as it work when i used to copy them from mplab , config bits in edit project in mikroc were also very different and it didnt work , when i use config setting in mikroc pro it did work , so i let start mikroc pro , if u know how can i set config bits in mikroc then tell please. | |
| |
| | #12 |
|
If you hook your LCD up like i showed you with the screen shot this works Code: // LCD module connections
sbit LCD_RS at RB2_bit;
sbit LCD_EN at RB3_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;
sbit LCD_RS_Direction at TRISB2_bit;
sbit LCD_EN_Direction at TRISB3_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;
// End LCD module connections
char txt1[] = "mikroElektronika";
char txt2[] = "EasyPIC5";
char txt3[] = "Lcd4bit";
char txt4[] = "example";
char i; // Loop variable
void Move_Delay() { // Function used for text moving
Delay_ms(500); // You can change the moving speed here
}
void main(){
TRISB = 0;
PORTB = 0xFF;
TRISB = 0xff;
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,6,txt3); // Write text in first row
Lcd_Out(2,6,txt4); // Write text in second row
Delay_ms(2000);
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Out(1,1,txt1); // Write text in first row
Lcd_Out(2,5,txt2); // Write text in second row
Delay_ms(2000);
// Moving text
for(i=0; i<4; i++) { // Move text to the right 4 times
Lcd_Cmd(_LCD_SHIFT_RIGHT);
Move_Delay();
}
while(1) { // Endless loop
for(i=0; i<8; i++) { // Move text to the left 7 times
Lcd_Cmd(_LCD_SHIFT_LEFT);
Move_Delay();
}
for(i=0; i<8; i++) { // Move text to the right 7 times
Lcd_Cmd(_LCD_SHIFT_RIGHT);
Move_Delay();
}
}
}
| |
| |
| | #13 |
|
Here a little video not real good but you can see how it works | |
| |
| | #14 |
|
Hey einton / be80be, I am interested to know if you resolved your issue. I'm having similar issues with an 4x20 LCD and a PIC18LF4580. I'm using mikroC PRO (09 version), and PICkit 2 programmer. I've copied and pasted the sample code, tried both PORT A and B, tried using RB2-RB7 rather than the RB0-RB05 pins that are in the documentation. Tried 2 different PIC18LF4580, tested every wire and rebuilt the circuit several times just in case I couldn't see an obvious errant connection (forest from the trees type error). The LCD lights up, the contrast adjustment works and I adjust the contrast I see that line 1 & 3 are solid. In fact this is the case if the PIC is not connected at all. I am buggered if I can work out why I don't get any text on the screen. Did you get yours working? if so, what was the fix? It seams so simple, yet I've spent hours trying to work it out. Any suggestions? Cheers, Doug. | |
| |
| | #15 |
|
Did you ground all unused pins on the LCD if not all you'll get is the is a bunch of square boxes when the LCD lights up
| |
| |
|
| Tags |
| lcd, mikroc, program |
| Thread Tools | |
| Display Modes | |
| |
Similar | ||||
| Title | Starter | Forum | Replies | Latest |
| Mikroc program problem | einton | Micro Controllers | 7 | 22nd July 2009 12:20 PM |
| MMC with PIC18F4550 using MiKroC | Nizar | Micro Controllers | 3 | 28th February 2009 02:14 PM |
| i need mikroC code | ouranix | Micro Controllers | 0 | 21st February 2009 02:31 PM |
| PIC Programming in MikroC | 00morrisd | Micro Controllers | 3 | 11th February 2009 10:22 PM |
| mikroC lib troubble | Kryten | Micro Controllers | 17 | 28th May 2008 09:56 AM |