mamech
Full Member level 3
Hello
I am using easypic6 .
I tried the GLCD example in mikroC on pic16887, and it worked well.
I tried to use PIC18F452 and I made the following modifications to the code:
There is no compilation error , but The glcd displays a big filled rectangle that fills all the screen !!!
What should be the source of this error ?
Thanks
Attachments : PIC18F452 Datasheet
View attachment 39564c.pdf
I am using easypic6 .
I tried the GLCD example in mikroC on pic16887, and it worked well.
I tried to use PIC18F452 and I made the following modifications to the code:
Code:
/*
* Project name:
GLCD_Test (Demonstration of the GLCD library routines)
* Copyright:
(c) Mikroelektronika, 2009.
* Revision History:
20081218:
- initial release;
- 20090720 - modified by Slavisa Zlatanovic;
* Description:
This is a simple demonstration of the GLCD library routines:
- Init and Clear (pattern fill)
- Image display
- Basic geometry - lines, circles, boxes and rectangles
- Text display and handling
* Test configuration:
MCU: PIC16F887
http://ww1.microchip.com/downloads/en/DeviceDoc/41291F.pdf
Dev.Board: EasyPIC6 - ac:GLCD
http://www.mikroe.com/eng/products/view/297/easypic6-development-system/
Oscillator: HS, 08.0000 MHz
Ext. Modules: GLCD 128x64, KS108/107 controller
http://www.mikroe.com/eng/categories/view/43/components/#other
SW: mikroC PRO for PIC
http://www.mikroe.com/eng/products/view/7/mikroc-pro-for-pic/
* Notes:
- Turn on GLCD backlight switch SW6.8.
*/
//Declarations------------------------------------------------------------------
const code char truck_bmp[1024];
//--------------------------------------------------------------end-declarations
// Glcd module connections
char GLCD_DataPort at PORTD;
sbit GLCD_CS1 at RB0_bit;
sbit GLCD_CS2 at RB1_bit;
sbit GLCD_RS at RB2_bit;
sbit GLCD_RW at RB3_bit;
sbit GLCD_EN at RB4_bit;
sbit GLCD_RST at RB5_bit;
sbit GLCD_CS1_Direction at TRISB0_bit;
sbit GLCD_CS2_Direction at TRISB1_bit;
sbit GLCD_RS_Direction at TRISB2_bit;
sbit GLCD_RW_Direction at TRISB3_bit;
sbit GLCD_EN_Direction at TRISB4_bit;
sbit GLCD_RST_Direction at TRISB5_bit;
// End Glcd module connections
void delay2S(){ // 2 seconds delay function
Delay_ms(2000);
}
void main() {
#define DRAWING_DEMO // Uncomment this line to see drawing routines demo
//#define TEXT_DEMO // Uncomment this line to see text routines demo
unsigned short counter;
char *someText;
ADCON1 = 0b0110; [B]// I closed here All analog pins according to the data sheet[/B]
// ANSEL = 0; // Configure AN pins as digital
//ANSELH = 0;
//C1ON_bit = 0; // Disable comparators
//C2ON_bit = 0;
Glcd_Init(); // Initialize GLCD
Glcd_Fill(0x00); // Clear GLCD
while(1) {
Glcd_Image(truck_bmp); // Draw image
Delay2s(); Delay2s();
Glcd_fill(0x00); // Clear GLCD
Glcd_PartialImage(0,0,68,30,128,64,truck_bmp); // Partial image
Delay_ms(500);
Glcd_PartialImage(24,16,68,30,128,64,truck_bmp);
Delay_ms(500);
Glcd_PartialImage(56,34,68,30,128,64,truck_bmp);
Delay2s(); Delay2s();
Glcd_Fill(0x00); // Clear GLCD
#ifdef DRAWING_DEMO
Glcd_Box(62,40,124,56,1); // Draw box
Glcd_Rectangle(5,5,84,35,1); // Draw rectangle
Delay_ms(1000);
Glcd_Rectangle_Round_Edges(2,2,87,38,7,1);
Delay_ms(1000);
Glcd_Rectangle_Round_Edges_Fill(8,8,81,32,12,1);
Delay_ms(1000);
Glcd_Line(0, 0, 127, 63, 1); // Draw line
Delay2s();
for(counter = 5; counter < 60; counter+=5 ){ // Draw horizontal and vertical lines
Delay_ms(250);
Glcd_V_Line(2, 54, counter, 1);
Glcd_H_Line(2, 120, counter, 1);
}
Delay2s();
Glcd_Fill(0x00); // Clear Glcd
for (counter = 1; counter <= 10; counter++) // Draw circles
Glcd_Circle(63,32, 3*counter, 1);
Delay2s();
for (counter = 1; counter <= 10; counter++) // Draw circles
Glcd_Circle_Fill(63,32, 3*counter, 1);
Delay2s();
Glcd_Box(12,20, 70,57, 2); // Draw box
Delay2s();
Glcd_Fill(0xFF); // Fill Glcd
#endif
#ifdef TEXT_DEMO
Glcd_Set_Font(Character8x7, 8, 7, 32); // Choose font, see __Lib_GLCDFonts.c in Uses folder
Glcd_Write_Text("TEXT DEMO", 24, 3, 2); // Write string
Delay2s();
Glcd_Fill(0x00); // Clear Glcd
Glcd_Set_Font(Character8x7, 8, 7, 32); // Change font
someText = "8x7 Font";
Glcd_Write_Text(someText, 5, 0, 2); // Write string
Delay2s();
Glcd_Set_Font(System3x5, 3, 5, 32); // Change font
someText = "3X5 CAPITALS ONLY";
Glcd_Write_Text(someText, 60, 2, 2); // Write string
Delay2s();
Glcd_Set_Font(font5x7, 5, 7, 32); // Change font
someText = "5x7 Font";
Glcd_Write_Text(someText, 5, 4, 2); // Write string
Delay2s();
Glcd_Set_Font(FontSystem5x7_v2, 5, 7, 32); // Change font
someText = "5x7 Font (v2)";
Glcd_Write_Text(someText, 50, 6, 2); // Write string
Delay2s();
#endif
}
}
There is no compilation error , but The glcd displays a big filled rectangle that fills all the screen !!!
What should be the source of this error ?
Thanks
Attachments : PIC18F452 Datasheet
View attachment 39564c.pdf
Last edited: