Problem with JHD240128D and PIC18F47k40

Status
Not open for further replies.

Jair.Hdez

Newbie level 3
Joined
Oct 18, 2017
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
41
Hi all,

I'm trying to use the GLCD JHD240128D with the PIC18F27K40 and mikroC v7.1.0 and the following code

Code:
#include        "__T6963C.h"

#define WATER   LATD.F0
#define TANK    LATD.F2

// T6963C module connections
char T6963C_dataPort at PORTC;
sbit T6963C_ctrlwr  at LATD7_bit;
sbit T6963C_ctrlrd  at LATD6_bit;
sbit T6963C_ctrlcd  at LATD4_bit;
sbit T6963C_ctrlrst at LATD3_bit;
sbit T6963C_ctrlwr_Direction  at TRISD7_bit;
sbit T6963C_ctrlrd_Direction  at TRISD6_bit;
sbit T6963C_ctrlcd_Direction  at TRISD4_bit;
sbit T6963C_ctrlrst_Direction at TRISD3_bit;
// End of T6963C module connections

// Signals not used by library, they are set in main function
sbit T6963C_ctrlce at LATD5_bit;                        // CE signal
sbit T6963C_ctrlfs at LATD1_bit;                        // FS signal
sbit T6963C_ctrlce_Direction  at TRISD5_bit;            // CE signal direction
sbit T6963C_ctrlfs_Direction  at TRISD1_bit;            // FS signal direction

int cuenta = 0;

void InitMCU();
void Init_Interrupt();

void interrupt()
{
        // Interrupcion TMR0
        if (PIR0.TMR0IF){
                TMR0L = 0x05;                           // Se carga la cuenta inicial en 65285 para 1ms.
                TMR0H = 0xFF;                           // ''

                cuenta++;
                if (cuenta >= 500) {
                        WATER = ~WATER;
                        cuenta = 0;
                }

                PIR0.TMR0IF = 0;                        // Reinicio de la bandera del bit de interrupción.
        }
}

void main() 
{
        InitMCU();
        Init_Interrupt();
        
        while (1) {
                //T6963C_write_text("Una cadena", 0, 0, T6963C_ROM_MODE_XOR);
                //T6963C_write_text("Otra cadena", 0, 15, T6963C_ROM_MODE_XOR);
                //T6963C_write_text("Otra cadena x2", 0, 30, T6963C_ROM_MODE_XOR);
                
                //T6963C_rectangle(40, 40, 199, 87, T6963C_WHITE);
        }
}

void InitMCU()
{
        ANSELA = 0x00;          // Digital o analogico
        ANSELC = 0x00;
        ANSELD = 0x00;
        ANSELE = 0x00;

        TRISA = 0x00;           // Entrada o salida
        TRISC = 0x00;
        TRISD = 0x00;
        TRISE = 0x00;

        TRISA.F5 = 1;           // Multiplexor entrada (Y)

        LATA = 0x00;            // Low o High
        LATC = 0x00;
        LATD = 0x00;
        LATE = 0x00;

        TANK = 1;
        delay_ms(200);
        TANK = 0;
        
        T6963C_ctrlce_Direction = 0;
        T6963C_ctrlce = 0;            // Enable T6963C
        T6963C_ctrlfs_Direction = 0;
        T6963C_ctrlfs = 0;            // Font Select 8x8
        
        // Initialize T6963C
        T6963C_init(240, 128, 8);
        TANK = 1;
        //WELL = 1;
        // Enable both graphics and text display at the same time
        //T6963C_graphics(1);
        //T6963C_text(1);
        
        // Cursor off
        //T6963C_cursor(0);
}

void Init_Interrupt()
{
        INTCON = 0xC0;                                        // GIE (Global Interrupt Enable) = 1, IPEN (Peripheral Interrupt Enable) = 1

        // TMR0 16bits
        T0CON0 = 0x90;                                        // Timer0 Enable - Timer de 16 bits
        T0CON1 = 0x46;                                        // Clock Source Fosc/4 - Prescaler 64
        PIE0 = 0x20;                                          // TMR0 Enable Interrupt
        TMR0L = 0x05;                                         // La cuenta inicia en 65285 para 1ms, Prescaler 64
        TMR0H = 0xFF;
}

My problem is when the program reach the line "T6963C_init(240, 128, 8);" the pic stops, I say this because my leds (WATER and TANK) don't blink. I attach my project.

The datasheet from the glcd is **broken link removed**

My conexions are:
JHD240128 -> PIC
1. FG -> 0V
2. GND -> 0V
3. VDD -> 5V
4. V0 -> Signal from a 10k pot (Vee and 0V)
5. WR -> RD7 (pin 30)
6. RD -> RD6 (pin 29)
7. CE -> RD5 (pin 28)
8. CD -> RD4 (pin 27)
9. RST -> RD3 (pin 22)
10 - 17. DB0 - DB7 -> RC0 - RC7 (pins 15 to 18 and 23 to 26)
18. FS -> RD1 (pin 20)
19. Vee -> one side of the 10k pot
20. LED+ -> 5V

Leds are in RD0 and RD2 (pis 19 and 21)
 

Attachments

  • FIRMWARE_DEON-UTR-PDS-V1_BASE_U1_v1.0.1.b.zip
    78.7 KB · Views: 74

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…