SK40C Work, But LCD FAILED

Programmer, In-Circuit Debugger, PIC Start-Up Kit, Memory Interface...

SK40C Work, But LCD FAILED

Postby pikachuX » Wed Jun 18, 2014 1:15 am

Hi guys,

I had burn the coding into the pic that provided from cytron sk40c page. But there is nothing happen after i burn in the program to pic. Is there any place i need to solder it ?

Is there necessary to buy the LCD from cytron ? because i buy the LCD from electronics shop.
Should be no problem right since the model also is 16x2 ?

I had solder all the pin like this.
Image

Coding:
CODE: SELECT_ALL_CODE
//==========================================================================
//   Author               : CYTRON   
//   Project               : SK40C Led Blinking
//   Project description      : Blink RB6 and RB7 LED
//                       This sample source code is valid for 20MHz crystal.
//                   
//==========================================================================

//   include
//==========================================================================
#include <pic.h>

//configuration
//==========================================================================
__CONFIG ( 0x3F32 );      //configuration for the  microcontroller

//   define
//==========================================================================
#define   rs         RB4         //RS pin of the LCD display
#define   e         RB5         //E pin of the LCD display

#define   lcd_data   PORTD      //LCD 8-bit data PORT

#define   SW1         RB0         
#define   SW2         RB1         

#define   LED1      RB6         
#define   LED2      RB7            

//   function prototype      (every function must have a function prototype)
//==========================================================================
void delay(unsigned long data);         
void send_config(unsigned char data);
void send_char(unsigned char data);
void lcd_goto(unsigned char data);
void lcd_clr(void);
void send_string(const char *s);
void uart_send(unsigned char data);



//   global variable
//==========================================================================

//   main function               (main fucntion of the program)
//==========================================================================
void main()
{
   unsigned long delay_time=5000;

   //set I/O input output
   TRISB = 0b00000011;            //configure PORTB I/O direction
   TRISD = 0b00000000;            //configure PORTD I/O direction
   TRISA = 0b00000111;            //configure PORTA I/O direction
   
   //setup ADC
   ADCON1 = 0b00000110;            //set ADx pin digital I/O
   
   //configure lcd
   send_config(0b00000001);         //clear display at lcd
   send_config(0b00000010);         //lcd return to home
   send_config(0b00000110);         //entry mode-cursor increase 1
   send_config(0b00001100);         //display on, cursor off and cursor blink off
   send_config(0b00111000);         //function set

   //display startup message   
   lcd_clr();                     //clear lcd
   lcd_goto(2);                  //set the lcd cursor to location 0
   send_string("Cytron Tech.");      //display "Cytron Tech."
   lcd_goto(26);                  //set the lcd cursor to location 20
   send_string("SK40C");            //display "SK40C"

   LED1=0;                        //OFF LED1
   LED2=0;                        //OFF LED2

   while(1)                     //Infinite loop
   {
      if(!SW1)                  //check if SW1 is pressed
      {
         while (!SW1);            //wait SW1 pressed
         {
            delay_time+=1000;      //delay
         }
      }
      else if(!SW2)               //check if SW2 is pressed
      {
         while (!SW2);            //wait SW2 pressed
         {
            delay_time-=1000;      //delay
         }
      }
      
      LED1^ = 1;               //toggle LED1
      delay(delay_time);            
      LED2^ = 1;               //toggle LED2         
      delay(delay_time);         
   }
}

//   functions
//==========================================================================
void delay(unsigned long data)         //delay function, the delay time
{                              //depend on the given value
   for( ;data>0;data--);
}

void send_config(unsigned char data)   //send lcd configuration
{
   rs=0;                        //set lcd to configuration mode
   lcd_data=data;                  //lcd data port = data
   e=1;                        //pulse e to confirm the data
   delay(50);
   e=0;
   delay(50);
}

void send_char(unsigned char data)      //send lcd character
{
    rs=1;                        //set lcd to display mode
   lcd_data=data;                  //lcd data port = data
   e=1;                        //pulse e to confirm the data
   delay(10);
   e=0;
   delay(10);
}

void lcd_goto(unsigned char data)      //set the location of the lcd cursor
{                              //if the given value is (0-15) the
    if(data<16)                     //cursor will be at the upper line
   {                           //if the given value is (20-35) the
       send_config(0x80+data);         //cursor will be at the lower line
   }                           //location of the lcd cursor(2X16):
   else                        // -----------------------------------------------------
   {                           // | |00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15| |
       data=data-20;               // | |20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35| |
      send_config(0xc0+data);         // -----------------------------------------------------   
   }
}

void lcd_clr(void)                  //clear the lcd
{
    send_config(0x01);
   delay(600);   
}

void send_string(const char *s)         //send a string to display in the lcd
{         
     while (s && *s)send_char (*s++);
}

void uart_send(unsigned char data)
{   
   while(TXIF==0);                  //only send the new data after
   TXREG=data;                     //the previous data finish sent
}




Regards,
YY
pikachuX
Novice
 
Posts: 18
Joined: Mon Sep 10, 2012 8:09 pm

Re: SK40C Work, But LCD FAILED

Postby ober » Wed Jun 18, 2014 8:49 am

Can you show the picture when the power is activated?
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm

Re: SK40C Work, But LCD FAILED

Postby pikachuX » Thu Jun 19, 2014 7:43 am

pikachuX
Novice
 
Posts: 18
Joined: Mon Sep 10, 2012 8:09 pm

Re: SK40C Work, But LCD FAILED

Postby ober » Thu Jun 19, 2014 8:07 am

OK, the power is working, LCD showing symptom that it is not initialize yet. How about LEDs? According to the sample code, both LEDs should blinking alternately.

As far as I use LCD, if the pins are compatible, the protocol should be compatible, task the sample code should work. If SK40C works but LCD is not working, do check the soldering of the LCD with SK40C.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm

Re: SK40C Work, But LCD FAILED

Postby Brian Griffin » Thu Jun 19, 2014 8:38 am

Resit the 20MHz crystal. Push it down and shake it a bit. It seems that the crystal is a bit loose on the SK40C boards.
PIC - UIC00B from Cytron (replacement for my broken PICKit 2), Pickit 3, MikroC for PIC
dsPIC - MikroC for dsPIC, mikromedia board (dsPIC33)
AVR - AVR Dragon
Parallax - Prop tool
User avatar
Brian Griffin
Enthusiast
 
Posts: 403
Joined: Mon Jan 17, 2011 9:36 am

Re: SK40C Work, But LCD FAILED

Postby pikachuX » Fri Jun 20, 2014 1:35 pm

i think the soldering should be no problem, because it not touching each others.

Image

Image

Image
pikachuX
Novice
 
Posts: 18
Joined: Mon Sep 10, 2012 8:09 pm

Re: SK40C Work, But LCD FAILED

Postby ober » Fri Jun 20, 2014 5:37 pm

Yes, it is not short between pins, but some of the pins seem to be not connected to SK40C, from the back, you need to verify that too.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm


Return to PIC Development Tool

Who is online

Users browsing this forum: No registered users and 2 guests