PDA

View Full Version : PIC18f2455 blink



iugmoh
- 3rd March 2008, 13:39
Hi all,
I need your help in begining with PIC18F2455 using PICbasic , I have alot of errors , I need a simple programm to beging with this IC.

skimask
- 3rd March 2008, 14:39
Hi all,
I need your help in begining with PIC18F2455 using PICbasic , I have alot of errors , I need a simple programm to beging with this IC.

The simple program would be the same simple program that is probably used for every other PIC you've programmed so far...

But...we don't know what you're errors are...so.............................

iugmoh
- 3rd March 2008, 14:50
When I compile the programm I have this error
MPASM Required

so i read and find that I must install MPLAB with MPASM , so it's woking now

skimask
- 3rd March 2008, 14:59
When I compile the programm I have this error
MPASM Required

so i read and find that I must install MPLAB with MPASM , so it's woking now

Believe it or not...the answer you seek is in the PBP manual near the beginning...
I know...not what you want to hear...but...well...there you go.

iugmoh
- 3rd March 2008, 15:10
Another question , I made a project on PIC16f877a but there isn't sufficient memory space to add additional code, so I change to PIC18F452 and make compile and it's compiled without any errors , IF I programm my chip and try practically Is't working ?

skimask
- 3rd March 2008, 15:16
Another question , I made a project on PIC16f877a but there isn't sufficient memory space to add additional code, so I change to PIC18F452 and make compile and it's compiled without any errors , IF I programm my chip and try practically Is't working ?

The 16F877A and 18F452 have different registers, different options, different modules, different things that need to be configured before use.
Something made for one probably isn't going to port DIRECTLY over to another PIC without a few register changes, configuration changes, from here to there.
Check the datasheets for the differences.
And if it works on the '877, go thru the code. There are ways of optimizing memory use on the '877 (both the program and ram space) to get things to fit.
Are you out of program space or ram space?

iugmoh
- 3rd March 2008, 16:26
program space is out

skimask
- 3rd March 2008, 16:27
program space is out

Well, same thing applies. There's a lot of different ways of optimizing code...but, without seeing any of it, can't say what will work for you.

iugmoh
- 3rd March 2008, 16:44
whats wrong in this code

for i=0 to 15
eeprom i,[0]
next i

skimask
- 3rd March 2008, 16:45
whats wrong in this code

for i=0 to 15
eeprom i,[0]
next i

Read the manual, last paragraph of the explanation for EEPROM.

iugmoh
- 3rd March 2008, 16:50
Oky, What is the different between EEPROM and DATA ?

skimask
- 3rd March 2008, 16:53
Oky, What is the different between EEPROM and DATA ?

Besides the obvious syntax differences between the two, not a lot, ALMOST identical.

You can make a DATA statement a 'readable' address, a label. Can't do that with the EEPROM statement.

iugmoh
- 3rd March 2008, 16:57
I understand that DATA is upgraded version of EEPROM

skimask
- 3rd March 2008, 17:32
I understand that DATA is upgraded version of EEPROM

Maybe......There is a difference. Either I can't remember, or I can't put my finger on it at the moment.
Of course there's always the chance that I just don't know :)

iugmoh
- 4th March 2008, 08:49
I change the PIC16f877A with PIC18F452 and nothing is working , so I will learn every thing step by step of PIC18f452

skimask
- 4th March 2008, 14:25
I change the PIC16f877A with PIC18F452 and nothing is working , so I will learn every thing step by step of PIC18f452

You really don't have to 'RELEARN' everything...because there really isn't anything to 'RELEARN'.
There is a document somewhere at Microchip that describes some basic differences between the '877 and the '452 that might help you out...

But...quite frankly, no code...not much help...'cause there just might be that one hidden thing that is stopping everything.

Have you made blinky LED work on the '452 yet?
And just because you've made it work on the '877 doesn't mean you can make it work on a '452....it should...but it doesn't.

iugmoh
- 4th March 2008, 19:00
Oky thanks skimask for your information I will try to make blink lea and see the differents

iugmoh
- 4th March 2008, 21:33
I try this code for blinking led on PIC18f452 , but nothing happened, the led always off , I use in this circuit 4MHZ XT crystal , 10K connected to MCLR TO +5v:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
trisb=0

main:
portb=0
pause 1000

portb=255
pause 1000

goto main

end

;;;;;;;;;;;;;;;;;;;;;;;;;

Here is 18F452.INC file
;************************************************* ***************
;* 18F452.INC *
;* *
;* By : Leonard Zerman, Jeff Schmoyer *
;* Notice : Copyright (c) 2005 microEngineering Labs, Inc. *
;* All Rights Reserved *
;* Date : 12/16/05 *
;* Version : 2.47 *
;* Notes : *
;************************************************* ***************
NOLIST
ifdef PM_USED
LIST
"Error: PM does not support this device. Use MPASM."
NOLIST
else
LIST
LIST p = 18F452, r = dec, w = -311, w = -230, f = inhx32
INCLUDE "P18F452.INC" ; MPASM Header
__CONFIG _CONFIG1H, _OSCS_OFF_1H & _XT_OSC_1H
__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H
__CONFIG _CONFIG4L, _LVP_OFF_4L
NOLIST
endif
LIST
EEPROM_START EQU 0F00000h
BLOCK_SIZE EQU 8

skimask
- 4th March 2008, 21:55
I try this code for blinking led on PIC18f452 , but nothing happened, the led always off , I use in this circuit 4MHZ XT crystal , 10K connected to MCLR TO +5v:


Connect the LED to MCLR...does it work then?
And let it run for at least 2 minutes.
Does the LED on PortB.0 change state?

iugmoh
- 4th March 2008, 21:58
when I connect Led to MCLR it work but with very low brightness, nothing happened to portb.0

skimask
- 4th March 2008, 21:59
yes it work but with very low brightness

What works?
MCLR or PortB.0?
Does it flash?
What's the value of your resistor?

iugmoh
- 4th March 2008, 22:05
oky , I connect MCLR -------> led through 470 ohm resistor , the brightness is very low, nothing happened to portb always off

skimask
- 5th March 2008, 13:54
oky , I connect MCLR -------> led through 470 ohm resistor , the brightness is very low, nothing happened to portb always off

The point of the LED on MCLR was to make sure that MCLR was actually getting pulled up to +5v.