View previous topic :: View next topic |
Author |
Message |
MegatroniC
Joined: 08 Dec 2009 Posts: 35
|
Help for PIC18F67K22 and LCD driver HDM64GS12.C |
Posted: Thu Mar 12, 2015 12:44 am |
|
|
Hello all.
I hope you can help me on this problem.
Display works without problems in the simulation.
http://s2.postimg.org/70t7onhqh/problem.jpg
But does not work in the real PCB. :(
Maybe not initialize because all voltages in the display are available.
Sometimes backlight only lights up, and sometimes displayed pixels randomly.
I have never encountered this in other chips, such as 18F4620, 18F46K22 ...
Here configuration:
HDM64GS12.C
Code: |
#ifndef HDM64GS12
#define HDM64GS12
#ifndef GLCD_WIDTH
#define GLCD_WIDTH 128
#endif
#ifndef GLCD_CS1
#define GLCD_CS1 PIN_E3 // Chip Selection 1
#endif
#ifndef GLCD_CS2
#define GLCD_CS2 PIN_E4 // Chip Selection 2
#endif
#ifndef GLCD_DI
#define GLCD_DI PIN_E5 // Data or Instruction input - RS pin
#endif
#ifndef GLCD_RW
#define GLCD_RW PIN_E6 // Read/Write
#endif
#ifndef GLCD_E
#define GLCD_E PIN_E7 // Enable
#endif
//#ifndef GLCD_DIT
//#define GLCD_DIT PIN_C0 // Reset
//#endif
|
test.h
Code: |
#include <18F67K22.h>
#FUSES WDT //Watch Dog Timer
#FUSES WDT1024 //Watch Dog Timer uses 1:1024 Postscale ->4.096s
#FUSES SOSC_DIG //Digital mode, I/O port functionality of RC0 and RC1
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES HSH //High speed Osc, high power 16MHz-25MHz
#FUSES NOIESO //Internal External Switch Over mode disabled
#FUSES PUT //Power Up Timer
#FUSES BORV20 //Brownout reset at 2.0V
#FUSES WDT_NOSLEEP //Watch Dog Timer, disabled during SLEEP
#FUSES PROTECT //Code protected from reads
#FUSES NOWRTD
#use delay(int=16000000,RESTART_WDT)
...
|
test.c
Code: |
void main()
{
gc_old_switch_status = read_switches(); // Read and save the initial state of the switches
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_64); //1.0 s overflow
setup_timer_1(T1_INTERNAL|T1_DIV_BY_2); //32.7 ms overflow
//setup_timer_2(T2_DIV_BY_16,250,10); //1.0 ms overflow, 10.0 ms interrupt
setup_timer_2(T2_DIV_BY_16,250,15); //1.0 ms overflow, 15.0 ms interrupt
setup_timer_3(T3_DISABLED);
setup_timer_4(T4_DISABLED,0,1);
setup_timer_5(T5_DISABLED);
setup_timer_6(T6_DISABLED,0,1);
setup_timer_7(T7_DISABLED);
setup_timer_8(T8_DISABLED,0,1);
setup_timer_10(T10_DISABLED,0,1);
setup_timer_12(T12_DISABLED,0,1);
setup_rtc(RTC_DISABLE);
setup_psp(PSP_DISABLED);
setup_spi(SPI_DISABLED);
//setup_uart(FALSE);
setup_adc(ADC_OFF);
setup_adc_ports(NO_ANALOGS);
setup_ccp1(CCP_OFF);
setup_ccp2(CCP_OFF);
setup_ccp3(CCP_OFF);
setup_ccp4(CCP_OFF);
setup_ccp5(CCP_OFF);
setup_ccp6(CCP_OFF);
setup_ccp7(CCP_OFF);
setup_ccp8(CCP_OFF);
setup_ccp9(CCP_OFF);
setup_ccp10(CCP_OFF);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
//ODCON1=0x00; //Open-drain capability is disabled
//ODCON2=0x00;
//ODCON3=0x00;
//port_d_pullups(0xFF);
//port_e_pullups(0xFF);
set_tris_a(0xBF);
set_tris_b(0x3F);
set_tris_c(0x00);
set_tris_e(0x00);
set_tris_f(0x00);
set_tris_g(0x00);
output_c(0x00);
delay_ms(500);
glcd_init(ON);
enable_interrupts(GLOBAL);
ReadStoreValue();
....
|
Perhaps I'm wrong settings for port D and port E ... |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Mar 12, 2015 1:00 am |
|
|
Your schematic doesn't show any connections to the LCD on pins 4 and 5,
which are Vdd and contrast.
Your Proteus schematic doesn't even show a connection for the backlight.
Post a schematic of your real hardware connections. |
|
|
MegatroniC
Joined: 08 Dec 2009 Posts: 35
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Thu Mar 12, 2015 1:22 am |
|
|
He is also setting the clock to use both the internal oscillator, and an external crystal....
The real chip needs the oscillator setup correctly. |
|
|
MegatroniC
Joined: 08 Dec 2009 Posts: 35
|
|
Posted: Thu Mar 12, 2015 2:25 am |
|
|
HSH -> #FUSES INTRC_IO //Internal RC Osc, no CLKOUT ?
The rest of the program works correctly, only the display does not work. |
|
|
MegatroniC
Joined: 08 Dec 2009 Posts: 35
|
|
Posted: Thu Mar 12, 2015 3:29 am |
|
|
I tried
output_d(0xFF);
output_e(0xFF);
and removing the initialization for LCD.
only RE5(RS for LCD) and RE7(E for LCD) stay at 0.
probably this is the reason for the problem, but why? |
|
|
MegatroniC
Joined: 08 Dec 2009 Posts: 35
|
|
Posted: Thu Mar 12, 2015 3:51 am |
|
|
Problem is solved!
With new 67К22.
Perhaps a manufacturing defect or soldering ...
Good Day to all! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Thu Mar 12, 2015 8:53 am |
|
|
MegatroniC wrote: | HSH -> #FUSES INTRC_IO //Internal RC Osc, no CLKOUT ?
The rest of the program works correctly, only the display does not work. |
You are just being lucky.....
HSH, is the fuse for High speed crystal/resonator, running in high power mode.
It is being overriden by your clock setting, and luckily happens to hit a combination that works. INTRC_IO is the fuse for internal RC oscillator no CLKOUT.
Look at the file 'fuses.txt' in your compiler directory, to find what each fuse 'name' does. |
|
|
|