View previous topic :: View next topic |
Author |
Message |
jesalf
Joined: 18 Jun 2010 Posts: 3
|
GLCD on DSPIC PRO 4 problem |
Posted: Sat Jun 19, 2010 4:02 pm |
|
|
Hi,
I have a problem with a graphic lcd connected to a dspic30F6014A. I used a dspic pro 4 board (from mikroe) and ccs compiler v 4.106.
I started with the glcd example and the left side of the glcd it´s ok but the right side has a type of offset. Then I tried a simple program to draw a horizontal line (pixel by pixel) from x=1 y=1 to x=127 y=1, and when the line cross the middle of the glcd it has a jump to y=120.
The same code but for a pic18F4550 works fine in Proteus. Also the same glcd but with MikroC works.
Is the HDM64GS12 driver is compatible with dspic?
Any one have been tried this GLCD with a DSPIC?
Or somebody have a driver for this glcd working with this dspic?
here is my code.
Code: |
#include <30F6014A.h>
#device ICD=TRUE
#fuses HS,NOWDT,PR
#use delay(clock=10000000)
#define FAST_GLCD
#include <G:\CCS_GLCD_Touchscreen_dsPIC PRO 4\HDM64GS12.c>
#include <G:\CCS_GLCD_Touchscreen_dsPIC PRO 4\graphics.c>
#include <math.h>
int i,j;
void main()
{
setup_adc_ports(sAN12);
setup_adc(ADC_CLOCK_INTERNAL);
set_adc_channel(12);
glcd_init(ON); // Must initialize the LCD
//GLCD_inicializa(1);
for(j=1;j<=63;j++)
{
for(i=1;i<=125;i++)
{
GLCD_PIXEL(i,j,1);
delay_ms(10);
}
}
} |
|
|
|
jesalf
Joined: 18 Jun 2010 Posts: 3
|
|
Posted: Sun Jun 20, 2010 9:27 pm |
|
|
in the last post I have a mistake, I wrote "it has a jump to y=120" it should be "it has a jump to y=57" since the glcd is a 128x64 pixels.
Thanks. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Jun 20, 2010 9:58 pm |
|
|
One difference between the PCH and the PCD compilers is that the default
data types are different.
The data types used in HDM64GS12.c are:
The PCH manual says:
Quote: |
Note: All types, except float , by default are unsigned; however,
they may be preceded by unsigned or signed.
|
The PCD manual says:
Quote: |
Note: All types, except char, by default are signed; however,
they may be preceded by unsigned or signed.
|
The fact that PCD variables are 'signed' by default is likely the cause
of your problems.
To fix this, you could:
1. Create a special version of the hdm64gs12.c file, and edit the file
so that all 'int8' and 'int16' declarations are preceded by 'unsigned'.
You could rename the file as hdm64gs12_pcd.c.
or
2. You could experiment with using the #type directive to change the
default behavior of the PCD compiler to be more like PCH. You could
put the following line at the start of the hdm64gs12.c file:
Then at the end of the file, set it back to normal for PCD:
It's possible that graphics.c might have the same problem. Many of the
variable declarations in graphics.c are declared as 'signed' and should
stay that way.
But, there are still a considerable number of plain 'int8' and 'int16'
declarations that will default to 'signed' in PCD when maybe they should
be 'unsigned'.
I don't have the PCD compiler so I can't test any of this. But these are
the areas where I think you need to look. |
|
|
jesalf
Joined: 18 Jun 2010 Posts: 3
|
|
Posted: Mon Jun 21, 2010 7:02 pm |
|
|
Thanks for the answer,
I took the second option and now it´s working!!
Thank you very much |
|
|
|