Page 1 of 2

No output after load program

PostPosted: Wed Feb 29, 2012 11:07 pm
by Harry88
I using PIC18F4550 with the sk40c. The program can be load but the PIC doesn't seen got any function.
Even i using a simple led turn on coding.
Any idea for my problems?

Hereby is my coding.

CODE: SELECT_ALL_CODE
#include <18F4550.h>
#fuses XT,NOWDT,NOLVP,NOPROTECT
#use delay (clock=20M)

#define LED1   PIN_B6
#define LED2   PIN_B7

#define SW1   PIN_B0
#define SW2   PIN_B1

void main()
{
set_tris_b(0x3F);
output_b(0x3F);

while(TRUE)
{
if (!input(SW1))
{
output_high(LED1);
output_low(LED2);
}

else if (!input(SW2))
{
output_high(LED2);
output_low(LED1);
}

else
{
}

}
}

Re: No output after load program

PostPosted: Thu Mar 01, 2012 6:27 am
by ABSF
Try changing #fuses XT to #fuses HS and see if it works.

See example here

#elif defined(__PCH__)
#include <18F452.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#endif



Allen

Re: No output after load program

PostPosted: Thu Mar 01, 2012 8:55 am
by Harry88
Thank a lot to ABSF, my kit is properly run now.
But i dun understand the standard coding need to include above there, did anybody suggest me where should i go for learn it?

Re: No output after load program

PostPosted: Thu Mar 01, 2012 12:44 pm
by ABSF
It is in the datasheet of 18F4550 under chapter 2.0 Oscillator Configurations. Look at table 2-2.

and also read chapter 25.1 configuration bits.

Allen

Re: No output after load program

PostPosted: Thu Mar 01, 2012 1:57 pm
by Harry88
Hello, i wan to ask for help.
now i using PIC18F4550 to control a 16x2 LCD.
the code i use is very simple and it is function.
but now i facing a problem since SK40c use the different ports wif my circuit.
Image
CODE: SELECT_ALL_CODE
#include <18F4550.h>
#fuses XT,NOWDT,NOLVP,NOPROTECT
#use delay (clock=4M)
#include <lcd.c>

#define BUTTON1   PIN_B0
#define BUTTON2   PIN_B1

#define LCD_E  PIN_D0
#define LCD_RS PIN_D1
#define LCD_RW PIN_D2
#define LCD_D4 PIN_D4
#define LCD_D5 PIN_D5
#define LCD_D6 PIN_D6
#define LCD_D7 PIN_D7

void main()
{
set_tris_b(0xFF);
output_b(0xFF);
lcd_init();

while(TRUE)
{
if (!input(BUTTON1))
{
lcd_putc("\fBUTTON 1");
}
else if (!input(BUTTON2))
{
lcd_putc("\f");
lcd_putc("\nBUTTON 2");
}
else
{
}
}
}


The SK40c port for lcd is as below
Image

Here is the coding but it is wrong, how is the way for me to control the RS,and E for the LCD?

CODE: SELECT_ALL_CODE
#include <18F4550.h>
#fuses HS,NOWDT,NOLVP,NOPROTECT
#use delay (clock=20M)
#include "lcd.c"

#define LED1   PIN_B6
#define LED2   PIN_B7
#define SW1   PIN_B0
#define SW2   PIN_B1

#define LCD_RS PIN_B4
#define LCD_E  PIN_B5
#define LCD_D0 PIN_D0
#define LCD_D1 PIN_D1
#define LCD_D2 PIN_D2
#define LCD_D3 PIN_D3
#define LCD_D4 PIN_D4
#define LCD_D5 PIN_D5
#define LCD_D6 PIN_D6
#define LCD_D7 PIN_D7

void main()
{
set_tris_b(0x3F);
set_tris_d(0x00);
output_b(0x3F);
output_b(0x00);
lcd_init();

while(TRUE)
{
lcd_putc("\fHello");
}

}

Re: No output after load program

PostPosted: Fri Mar 02, 2012 12:01 pm
by ABSF
The LCD.c will either pick PORTB or PORTD for the LCD interfacing.

As you're using PORTD you need to uncomment the line
#locate lcd = getenv("sfr:PORTD") // This puts the entire structure over the port
in LCD.c as in your #included file.

You also need to add delay on the LCD after displaying your text. Like this

CODE: SELECT_ALL_CODE
void main()
{
set_tris_b(0x3F);
set_tris_d(0x00);
output_b(0x3F);
output_b(0x00);
lcd_init();
lcd_gotoxy(1,1);
while(TRUE)
{
lcd_putc("\fHello");
delay_ms(10000);
}
}


Allen

Re: No output after load program

PostPosted: Thu Feb 27, 2014 11:34 am
by karthi06
Hi,i have created a simple program for lcd display and burn the program into Pic18f46k22 controller.But,when tested it in hardware.May i know why this happens ?

Thank you.

Re: No output after load program

PostPosted: Thu Feb 27, 2014 9:22 pm
by ober
Are you sure the program for LCD is working properly? Have you check the connection of LCD to microcontroller? Is the program being loaded into the controller?

Re: No output after load program

PostPosted: Sun Mar 02, 2014 8:46 pm
by karthi06
I program the PIC,using the pickit2 from cytron.Once i clicked the write button,it says the program programmed successfully.But when i tested it in hardware no output seen.In this case,the lcd doesn't display characters.I take out the PIC and put it back into pickit2,and found that the memory is cleared/erased.But previously the same pickit2 informs me it is programmed successfully.May i know why this happens ?

Thank you.

Re: No output after load program

PostPosted: Tue Mar 04, 2014 8:26 am
by ober
If you have the code protected when you load program, programmer will read "cleared" memory when it read back.

Please show us the hardware connection and the code, both the code and hardware must be correct in order for it to work.