PDA

View Full Version : Pic 18f4620



78Davide
- 5th May 2009, 16:50
Hi, I am beginning to program pic with pickit 2; I use micro code studio as compiler, (pbp). I have a problem with pic 18f4620.

I make this simple program, lampled, but the flashing of the led does not correspond with the program( 1 second on, 1 second off), synchronism lacks.

This is the program:
'************************************************* ***************
'* Name : UNTITLED.BAS *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2009 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 27/04/2009 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************

DEFINE OSC
TRISB = %00000000
PORTB = 0

START:
PORTB.1 = 1
PAUSE 1000
PORTB.1 = 0
PAUSE 1000
GOTO START
++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++

The problem is the configuration fuses?
Tank's Davide.

mister_e
- 5th May 2009, 17:03
Yes and No, you haven't told us which osc speed you're using :o

Problem lie more on PORTB.1 and it's multiplexed Analog To digital converter. You want to disable it before using it as digital i/o

Here's some link for you, keep them handy somewhere.

PortA Doesn't Work
http://www.picbasic.co.uk/forum/showthread.php?t=561

All Digital
http://www.picbasic.co.uk/forum/showthread.php?t=11100

Presetting Configuration Fuses (PIC Defines) into your Program
http://www.picbasic.co.uk/forum/showthread.php?t=543

78Davide
- 6th May 2009, 15:15
'************************************************* ***************
'* Name : UNTITLED.BAS *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2009 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 27/04/2009 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************

DEFINE OSC 20
TRISB = %00000000
PORTB = 0

START:
PORTB.1 = 1
PAUSE 1000
PORTB.1 = 0
PAUSE 1000
GOTO START
++++++++++++++++++++++++++++++++++++++++++++++++++ ++


The frequency is 20 MHz.

Archangel
- 6th May 2009, 19:24
Hello Davide,
You have no config settings in your code which indicates to me you are using the default config listed in the pbp\18f4620.inc file, which was designed for 4mhz operation, so you have to either change those configs, comment them out and put the correct ones into your code, or change your resonator and define to 4mhz. Look at the links provided by mister_e.