No output after load program

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

No output after load program

Postby Harry88 » Wed Feb 29, 2012 11:07 pm

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
{
}

}
}
Harry88
Freshie
 
Posts: 4
Joined: Wed Feb 29, 2012 10:58 pm

Re: No output after load program

Postby ABSF » Thu Mar 01, 2012 6:27 am

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
The next war will determine NOT who is right BUT what is left.
User avatar
ABSF
Professional
 
Posts: 810
Joined: Wed Nov 10, 2010 9:32 am
Location: E Malaysia

Re: No output after load program

Postby Harry88 » Thu Mar 01, 2012 8:55 am

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?
Harry88
Freshie
 
Posts: 4
Joined: Wed Feb 29, 2012 10:58 pm

Re: No output after load program

Postby ABSF » Thu Mar 01, 2012 12:44 pm

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
The next war will determine NOT who is right BUT what is left.
User avatar
ABSF
Professional
 
Posts: 810
Joined: Wed Nov 10, 2010 9:32 am
Location: E Malaysia

Re: No output after load program

Postby Harry88 » Thu Mar 01, 2012 1:57 pm

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");
}

}
Harry88
Freshie
 
Posts: 4
Joined: Wed Feb 29, 2012 10:58 pm

Re: No output after load program

Postby ABSF » Fri Mar 02, 2012 12:01 pm

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
The next war will determine NOT who is right BUT what is left.
User avatar
ABSF
Professional
 
Posts: 810
Joined: Wed Nov 10, 2010 9:32 am
Location: E Malaysia

Re: No output after load program

Postby karthi06 » Thu Feb 27, 2014 11:34 am

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.
karthi06
Novice
 
Posts: 17
Joined: Mon Feb 24, 2014 8:47 pm

Re: No output after load program

Postby ober » Thu Feb 27, 2014 9:22 pm

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?
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: No output after load program

Postby karthi06 » Sun Mar 02, 2014 8:46 pm

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.
karthi06
Novice
 
Posts: 17
Joined: Mon Feb 24, 2014 8:47 pm

Re: No output after load program

Postby ober » Tue Mar 04, 2014 8:26 am

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.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm

Next

Return to PIC Development Tool

Who is online

Users browsing this forum: No registered users and 6 guests

cron