![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Paularina Guest
|
Driving Custom using 18F65J90 |
Posted: Wed Aug 05, 2009 11:11 pm |
|
|
Hi,
I am trying to drive custom LCD with PIC that has integrated LCD driver.
The problem is that the driver correctly displays the specified segments, but with after image on all the other commons.
For example, say that LCD segment ABCD, are tied to one PIC segment pin. but with different Commons. For example, A => Seg0, Com0, B => Seg0,Com1, C=> Seg0, Com2, D = Seg0, Com3
When I try to turn on only segment A, all the other segments turn on. Although segments B,C,D are less bright, they are nevertheless intolerable. As the problem makes it difficult to read the display.
I have played with codings in order to fix the problem by changing waveform, prescaling rate, and many other relevent LCD control registers, but with no avail.
I will provide the coding below, but i think it is the hardware problem.
I am using M3 mode(with register ladder and hardware contrast)
The parts that are commented out are there because I have played with program a bit.
Also, I have tried to changing Multiplex mode to use only Com0. However, the problem still remains.
I will appreciate any ideas
Code: |
//Main.c
#include<18F65J90.h>
#include<def_18F65J90.h>
#fuses intrC
#use delay(clock = 32000)
//****************DP*******G*********F*******E********D********C********B*******A***
#define DIGIT1 COM0+0, COM2+31, COM3+31, COM1+31, COM0+31, COM1+0, COM2+0, COM3+0
#define DIGIT2 COM0+2, COM2+1, COM3+1, COM1+1, COM0+1, COM1+2, COM2+2, COM3+2
#define DIGIT3 COM0+4, COM2+3, COM3+3, COM1+3, COM0+3, COM1+4, COM2+4, COM3+4
#define DIGIT4 COM0+6, COM2+5, COM3+5, COM1+5, COM0+5, COM1+6, COM2+6, COM3+6
#define DIGIT5 COM0+9, COM2+7, COM3+7, COM1+7, COM0+7, COM1+9, COM2+9, COM3+9
#define DIGIT6 COM0+24, COM2+25, COM3+25, COM1+25, COM0+25, COM1+24, COM2+24, COM3+24
#define DIGIT7 COM0+22, COM2+23, COM3+23, COM1+23, COM0+23, COM1+22, COM2+22, COM3+22
#define DIGIT8 COM0+20, COM2+21, COM3+21, COM1+21, COM0+21, COM1+20, COM2+20, COM3+20
#define DIGIT9 COM0+19, COM2+26, COM3+26, COM1+26, COM0+26, COM1+19, COM2+19, COM3+19
#define DIGIT10 COM0+15, COM2+18, COM3+18, COM1+18, COM0+18, COM1+15, COM2+15, COM3+15
#define DIGIT11 COM0+13, COM2+29, COM3+29, COM1+29, COM0+29, COM1+13, COM2+13, COM3+13
#define DIGIT12 COM0+16, COM2+17, COM3+17, COM1+17, COM0+17, COM1+16, COM2+16, COM3+16
#define DIGIT13 COM0+11, COM2+12, COM3+12, COM1+12, COM0+12, COM1+11, COM2+11, COM3+11
//dot_places 1 2 3 4 4 6 7 8
#define dotL COM3+22, COM1+23, COM0+23, COM2+23, COM3+23, COM2+22, COM1+22, COM0+22
//dot_places 9 10 11 12 12 12 12 12
#define dotH COM3+22, COM1+23, COM0+23, COM2+23, COM3+23, COM2+22, COM1+22, COM0+22
//mode definition
// T1(m3) T2(LIT) T3(NM3) T4(NLIT) T4 T4 T4 T4
#define rate_volume_mode COM3+22, COM1+23, COM0+23, COM2+23, COM3+23, COM2+22, COM1+22, COM0+22
// /SEC /MIN /HR /DAY /DAY /DAY /DAY /DAY
#define rate_time_mode COM3+22, COM1+23, COM0+23, COM2+23, COM3+23, COM2+22, COM1+22, COM0+22
// T5(M3) T6(LIT) T3(NM3) T4(NLIT3) T4 T4 T4 T4
#define total_volume_mode COM3+22, COM1+23, COM0+23, COM2+23, COM3+23, COM2+22, COM1+22, COM0+22
//indexing
#DEFINE EMPTY 10
#DEFINE A 11
#DEFINE C 12
#DEFINE D 13
#DEFINE E 14
#DEFINE F 15
#DEFINE I 16
#DEFINE N 17
#DEFINE O 18
#DEFINE P 19
#DEFINE T 20
#DEFINE U 21
#DEFINE L 22
#DEFINE DASH 23
#DEFINE M_PART 24 //second part of m i.e. n+mpart = m
const int8 DIGIT_MAP[25]= {0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x27, 0x7F, 0x67
,0X00, 0X77, 0X39, 0X5E, 0X79, 0X71, 0X06, 0X54, 0X5C, 0X73
,0X78, 0X3E,0x38, 0X40, 0X88};
//Mode flags
int8 mode_flag1;
//#bit ACC_TOT_MODE = mode_flag.1
#bit WA = LCDPS.4
void LCD_init(void){
LCDPS = 0b0010000; //WFT = 0(Type A waveform), BIASMD = 0(1/4 bias),
//LCDA = 1(lcd drive module is active), WA = 1(write allowed), LP = 0011(prescaling = 8:1)
//LCDSEx definition
LCDSE0 = 0xFF; //SEG<7:0> All Segment control
LCDSE1 = 0xFF;
LCDSE2 = 0xFF; //SEG<23:16> All segment control
LCDSE3 = 0XFF;
//LCDCON setup
LCDCON = 0b00011011; // LCDEN = 1, /SLPEN = 1, WERR = 0,unimplemented, CS<1:0> = 10(LFINTOSC/32), LMUX<1:0> = 11(use 4 commons)
}
//void display_rtn(void){
void init_rtn(void){
osccon = 0x01;
LCD_INIT();
}
void main(void){
int8 counter;
int8 counter0;
init_rtn();
//lcd_symbol(digit_map[0], digit3);
//lcddata0 = 0b00000010;
trisb = 0x00;
portb = 0b01000000;
LCDREG = 0B00111100;//Unemplemented, CPEN = 0, BIAS<2:0> = 111, MODE13 = 1, CKSEL<1:0> = 00(regulator disabled)s
PIR3 &=0b10111111;
LCDCON |= 0b10000000;
/*
while(1){
if(WA) lcd_symbol(digit_map[0], digit3);
if(WA) lcd_symbol(digit_map[4], digit4);
if(WA) lcd_symbol(digit_map[5], digit5);
if(WA) lcd_symbol(digit_map[6], digit6);
if(WA) lcd_symbol(digit_map[7], digit7);
if(WA) lcd_symbol(digit_map[8], digit8);
if(WA) lcd_symbol(digit_map[9], digit9);
if(WA) lcd_symbol(digit_map[10], digit10);
if(WA) lcd_symbol(digit_map[11], digit11);
if(WA) lcd_symbol(digit_map[12], digit12);
if(WA) lcd_symbol(digit_map[13], digit13);
}
*/
while(1){
delay_ms(1000);
if(wa) lcddata0 = 0xFF;
delay_ms(1000);
if(wa) lcddata0 = 0x01;
}
/*
while(1){
for(counter = 0; counter<=9; counter++){
for(counter0 = 0; counter0<=99; counter0++){
delay_ms(10);
}
lcd_symbol(digit_map[counter], digit1);
lcd_symbol(digit_map[9-counter], digit2);
}
LCDPS = 0b00110001;
lcd_symbol(digit_map[1], digit3);
for(counter = 0; counter<=9; counter++){
for(counter0 = 0; counter0<=99; counter0++){
delay_ms(10);
}
lcd_symbol(digit_map[counter], digit1);
lcd_symbol(digit_map[9-counter], digit2);
}
LCDPS = 0b00110011;
lcd_symbol(digit_map[2], digit3);
for(counter = 0; counter<=9; counter++){
for(counter0 = 0; counter0<=99; counter0++){
delay_ms(10);
}
lcd_symbol(digit_map[counter], digit1);
lcd_symbol(digit_map[9-counter], digit2);
}
LCDPS = 0b00110111;
lcd_symbol(digit_map[3], digit3);
for(counter = 0; counter<=9; counter++){
for(counter0 = 0; counter0<=99; counter0++){
delay_ms(10);
}
lcd_symbol(digit_map[counter], digit1);
lcd_symbol(digit_map[9-counter], digit2);
}
LCDPS = 0b00111000;
lcd_symbol(digit_map[4], digit3);
for(counter = 0; counter<=9; counter++){
for(counter0 = 0; counter0<=99; counter0++){
delay_ms(10);
}
lcd_symbol(digit_map[counter], digit1);
lcd_symbol(digit_map[9-counter], digit2);
}
LCDPS = 0b00111001;
lcd_symbol(digit_map[5], digit3);
for(counter = 0; counter<=9; counter++){
for(counter0 = 0; counter0<=99; counter0++){
delay_ms(10);
}
lcd_symbol(digit_map[counter], digit1);
lcd_symbol(digit_map[9-counter], digit2);
}
LCDPS = 0b00111010;
lcd_symbol(digit_map[6], digit3);
for(counter = 0; counter<=9; counter++){
for(counter0 = 0; counter0<=99; counter0++){
delay_ms(10);
}
lcd_symbol(digit_map[counter], digit1);
lcd_symbol(digit_map[9-counter], digit2);
}
LCDPS = 0b00111101;
lcd_symbol(digit_map[7], digit3);
for(counter = 0; counter<=9; counter++){
for(counter0 = 0; counter0<=99; counter0++){
delay_ms(10);
}
lcd_symbol(digit_map[counter], digit1);
lcd_symbol(digit_map[9-counter], digit2);
}
LCDPS = 0b00111110;
lcd_symbol(digit_map[9], digit3);
for(counter = 0; counter<=9; counter++){
for(counter0 = 0; counter0<=99; counter0++){
delay_ms(10);
}
lcd_symbol(digit_map[counter], digit1);
lcd_symbol(digit_map[9-counter], digit2);
}
LCDPS = 0b00111111;
lcd_symbol(digit_map[P], digit3);
for(counter = 0; counter<=9; counter++){
for(counter0 = 0; counter0<=99; counter0++){
delay_ms(10);
}
lcd_symbol(digit_map[counter], digit1);
lcd_symbol(digit_map[9-counter], digit2);
}
}
*/
}
|
|
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Aug 06, 2009 12:03 am |
|
|
Quote: | #include<18F65J90.h>
#include<def_18F65J90.h>
#fuses intrC
#use delay(clock = 32000) |
In the LCD section, the 18F65J90 data sheet expects you to configure
the PIC's internal oscillator for 32 MHz, not 32 KHz as you have it above.
Quote: |
• INTRC source
15.2.2 CLOCK SOURCE CONSIDERATIONS
When using the system clock as the LCD clock source, it is
assumed that the system clock frequency is a nominal 32 MHz.
|
18F65J90 data sheet:
http://ww1.microchip.com/downloads/en/DeviceDoc/39770b.pdf
I suggest that you change the #use delay() statement to use 32 MHz.
1. Post your compiler version.
2. If you need more help, then post a schematic or diagram of the LCD,
which shows the internal connections between the Segments, Commons
and the LCD pins.
3. Post a list of connections between the PIC pins and the LCD pins. |
|
![](templates/subSilver/images/spacer.gif) |
paularina Guest
|
|
Posted: Thu Aug 06, 2009 2:50 am |
|
|
Quote: | #include<18F65J90.h>
#include<def_18F65J90.h>
#fuses intrC
#use delay(clock = 32000)
In the LCD section, the 18F65J90 data sheet expects you to configure
the PIC's internal oscillator for 32 MHz, not 32 KHz as you have it above.
Quote:
• INTRC source
15.2.2 CLOCK SOURCE CONSIDERATIONS
|
I have tried changing 32000 to 32000000. But it didn't work.
I have also tried with osccon statement commented out still with no avail.
I am using the internal oscillator and I don't know how I can set the clock frequency above 8Mhz.
Also, if I have tried scrolling prescaling ratio (LCDPS<3,0>) from 0000 to 1111 but it didn't work.
1. My compiler version is 4.057
2.3 I am using M3 mode in which
LCDBIAS3 is connected to 3V
LCDbias2 is connected to 2V
LCDBIAS1 is connected to 1V
LCDBIAS0 is connected to 0V.
The register ladder is constructed with 3 10K ohm registers(also tried with 3 1M ohm).
As for LCD pins, there are 4 common pins and 29 segment pins.
For powering the IC, All Vss and Vdd are connected normally and VddCore pin is connected to the ground through a capacitor.
Thanks |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Aug 06, 2009 11:54 am |
|
|
Quote: |
I am using the internal oscillator and I don't know how I can set the clock frequency above 8Mhz. |
I made a mistake on that. Apparently, you can't run the PLL from the
8 MHz internal oscillator. The oscillator diagram shows this. (I was only
looking at the LCD section initially). The PLL will only run from an
external crystal or external oscillator.
Connect an 8 MHz crystal (and associated capacitors) to the OSC1 and
OSC2 pins on the PIC. Then add the items shown in bold below. This
will enable the 4x PLL and you should get a 32MHz clock for your PIC.
Quote: |
#include <18F65J90.h>
#fuses H4_SW, NOWDT
#use delay(clock=32000000)
//============================
void main()
{
setup_oscillator(OSC_PLL_ON);
while(1);
} |
|
|
![](templates/subSilver/images/spacer.gif) |
paularina Guest
|
|
Posted: Thu Aug 06, 2009 6:45 pm |
|
|
First of all, thank you for your prompt reply
Do I "have to" setup the system clock speed to 32Mhz? Setting the clock speed that high will adversely effect the battery life as I am designing Low power application.
The data sheet says
Quote: |
Because the prescaler option for the FOSC/4 clock
selection is fixed at divide-by-8192, system clock
speeds that differ from 32 MHz will produce frame
frequencies and refresh rates different than discussed
in this chapter. The user will need to keep this in mind
when designing the display application.
|
So, if I use Fosc = 1Mhz, 1Mhz/4/8192 = 32Hz
Also, Can I just use INTRC source(div by 32) to generate 1Khz clock? |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Aug 06, 2009 7:08 pm |
|
|
Yes, I think you can do it. I didn't realize you wanted very low power
operation. The lcd clock diagram in the PIC data sheet shows that it
should work.
But what about posting a schematic of the LCD and a list of the
connections between the PIC pins and the LCD pins ? |
|
![](templates/subSilver/images/spacer.gif) |
paularina Guest
|
|
Posted: Thu Aug 06, 2009 10:27 pm |
|
|
I think I solved the problem.
The reason was that I did not clear the LCDEN bits that corresponds to SEG pins that are not being used by the LCD driver.
As you could notice from the code I posted above, I just carelessly enabled all LCD segments from 0 to 31. However, I was not using some of the segments in between. For example, I was using seg14 pin for push key and seg27 and 28 for UART.
I did not know that setting the LCD enable bit for the segments that are not connected to LCD would cause that big of a problem.
For schematics, it is very difficult for me to draw it as I am not familiar(actually no experience) with CAD.
Thank you for your support.. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Aug 06, 2009 11:20 pm |
|
|
Well, the truth is, if you have a custom LCD then you have gone through
a design process with the manufacturer and you will have specified the
connections between the segments and the LCD pins, and also between
the COMx pins and the LCD pins. You will have this document.
It could be scanned and posted.
I know this, because we bought a custom LCD at our company, and I
specified all these things and we do have a drawing.
But you don't need to post it since you got it all working. That's good. |
|
![](templates/subSilver/images/spacer.gif) |
paularina Guest
|
|
Posted: Fri Aug 07, 2009 2:40 am |
|
|
Your comment is absolutely true.
However, there are two people working on this project and I am only in charge of software because of my lack of knowledge regarding hardware.
I AM provided with schematics but did not have the scanning device available in my working environment. Redrawing the schematics would have been a real pain for me.
By the way, thank you for your support. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|