PDA

View Full Version : 18f4550



ngeronikolos
- 16th June 2007, 14:42
Hi to every picbasic crazy brain,

I have an experiance in pic16f628.
I decide to do the next step to pic's.So i choose the 18f4550.

Please I need a sample code to begin with a blink led.

PicBsic pro 2.47
PICKIT2
MPLAB IDE v7.60

Thanks in advance
Nikos

skimask
- 16th June 2007, 18:08
Hi to every picbasic crazy brain,

I have an experiance in pic16f628.
I decide to do the next step to pic's.So i choose the 18f4550.

Please I need a sample code to begin with a blink led.

PicBsic pro 2.47
PICKIT2
MPLAB IDE v7.60

Thanks in advance
Nikos

Since you have PBP 2.47, there is an example in the book.

ngeronikolos
- 16th June 2007, 18:10
Hello,

Please help I need sample code for my first program on PIC18F4550.

Thanks in advanve
Nikos

skimask
- 16th June 2007, 18:19
Hello,

Please help I need sample code for my first program on PIC18F4550.

Thanks in advanve
Nikos

Refer to post #2!!! Section 2.2

keithdoxey
- 16th June 2007, 18:39
I have an experiance in pic16f628.
I decide to do the next step to pic's.So i choose the 18f4550.

Please I need a sample code to begin with a blink led.



Why not just put one of your existing programs on the 18F4550 ?

Or are you asking for a sample program to test some of the additional features on the device (which probably wouldnt be needed for "Blink LED")

ngeronikolos
- 16th June 2007, 18:54
ok

Let's say that I am going to use the code from 16f628 to blink a led in Porta.1

loop:
High PORTA.1 'Turn on LED
Pause 500 ' Delay for .5 seconds
Low PORTA.1 'Turn off LED
Pause 500 ' Delay for .5 seconds
Goto loop ' Go back to loop and blink LED forever
End

How I will use the internal osc?

In 16f628 i did this:
@ DEVICE pic16f628, INTRC_OSC_NOCLKOUT

Now it did not work.
What else it needs to work?

Nikos

keithdoxey
- 16th June 2007, 19:22
ok
How I will use the internal osc?

In 16f628 i did this:
@ DEVICE pic16f628, INTRC_OSC_NOCLKOUT

Now it did not work.
What else it needs to work?

Nikos

How did you find out how to set the Internal Oscilator for the 16F628 ?

Presumably by looking in the datasheet for the device to see what needed to be configured.

By looking in the datasheet for any PIC you will be able to find what needs to be set. It may take a few tries before you get the correct results but that is how you learn....from your mistakes.

Also read the sections about Analogue Ports and Comparators.

mister_e
- 16th June 2007, 20:39
What the heck happen on this forum since few weeks/months?

Guys, if you can't help, don't answer, don't waste your/our time and bandwith.

Even if this is a simple question, 18F4550 have tons of Configuration fuse to set. Can be enough to stop someone to use it.

There's really a lot of a s s kicking to do here :mad:

--------------------------------------------------------------------------

ngeronikolos,

have a look at the following, OK, it's more than a LED blink, but this should give you some hints at least about the config fuses settings.

http://www.picbasic.co.uk/forum/showthread.php?t=5418&highlight=pic18f4550

HTH

skimask
- 16th June 2007, 22:48
What the heck happen on this forum since few weeks/months? Guys, if you can't help, don't answer, don't waste your/our time and bandwidth. Even if this is a simple question, 18F4550 have tons of Configuration fuse to set. Can be enough to stop someone to use it. There's really a lot of a s s kicking to do here :mad:


Because...even without setting config registers (I suppose depending on the programmer and any previous settings that might be 'locked in'), the '4550 will start up (as most newer PICs will) with a 1Mhz internal clock (depending on the PIC model), not perfect, but enough to get things up and running... especially the ol' "blinky led" type program.
And...You and I both know that the '628 blinky led program wasn't going to work as expected in the earlier post since there is no mention of the ADCON CMCON registers. This is all mentioned in the PBP manual under section 2.5, which is labeled I've Got Troubles, where it specifically mentions the comparator and the analog ports, not to mention the issues with RA4, all of which seem to plague SOOOO many people. But that assumes that the person has a copy of the book.
And as far as the pins being configured as inputs on reset, the HIGH and LOW statement for the 'blinky led' program should take care of that.

mister_e
- 16th June 2007, 22:56
i know you wanted to say CMCON for the 16F628 ;)

Darrel Taylor
- 17th June 2007, 04:36
Because...even without setting config registers (I suppose depending on the programmer and any previous settings that might be 'locked in'), the '4550 will start up (as most newer PICs will) with a 1Mhz internal clock

Except that the default config settings in the .INC files for these chips are for a 20Mhz crystal, using the PLL to get 48Mhz to both USB and CPU.

Maybe if you tell the programmer not to write the config settings it might .. stress might, come up with the internal oscillator, but NOT defining the required conditions, and hoping it does what you want, is obviously NOT the right way to do things.

And, while we're on the subject of the "right way to do things" ...

When someone asks a question on the Forum, the "right way" is to attempt to provide an answer.
Pointing them to Section 2.2 of the Manual (Your First Program), is just plain Rude!<hr>
Now, for that "Answering the question" part...
Oh, and let me add here that it's preferable to have actually tested the answers you give.
Pull out the 4550, plug it in a breadboard and make sure you're giving an answer, not more problems for the person to deal with.

In my case it's easy... Just pull out the mister_e 18F4550 USB Demo prototype (minus a few LED's) from
http://www.picbasic.co.uk/forum/showthread.php?p=31405
(Yup, I keep them.)

Which then allows me to present the following post, with great confidence that it'll work. Because I've actually done it.
<br>

Darrel Taylor
- 17th June 2007, 04:36
Nikos,

If you haven't already, it's best to comment out the default oscillator settings in the 18F4550.inc file in the PBP folder, I'm sure you've done that before with other PIC's ...

Then you can set the options in your main program.
Here's a possibility for blinking an LED on PORTA.1 with a 4550 using the Internal Oscillator @4Mhz and your original code ...
'18F4550 with Int OSC Blinky

@ __CONFIG _CONFIG1H, _FOSC_INTOSC_XT_1H

DEFINE OSC 4 ; CPU runs @ 4 Mhz
OSCCON = %01100010 ; 4 Mhz Internal Oscillator

;DEFINE OSC 8 ; CPU runs @ 8 Mhz
;OSCCON = %01110010 ; 8 Mhz Internal Oscillator

ADCON1 = $0F ; Disable Analog inputs

loop:
High PORTA.1 'Turn on LED
Pause 500 ' Delay for .5 seconds
Low PORTA.1 'Turn off LED
Pause 500 ' Delay for .5 seconds
Goto loop ' Go back to loop and blink LED forever

End
Keep in mind that the internal oscillator can't drive the USB module. But you can add a crystal to drive the USB and still run the CPU on Internal. Your choice.

HTH,

ngeronikolos
- 21st June 2007, 16:27
Thanks to every one that want to help and share with us a piece of his
(or her) experience.

According to Darrel and his piece of his program, I have a problem.
I used to use Micrcode studio Plus for 16f628.
Now with the 18f4550 I need the MPLAB.So, I download the latest version of it and set it up to me laptop.
I did what the microEngineering Labs says about the :
--The PICBASIC™ and PICBASIC PRO™ Compilers can now be used with Microchip's MPLAB®!--
http://www.melabs.com/support/mplab.htm

After all that I try to compile the 18F4550 with Int OSC Blinky that Darrel post and I get two errors Error[118] look at the attached photo

Please advice
Nikos

mister_e
- 21st June 2007, 16:45
http://www.picbasic.co.uk/forum/showpost.php?p=6775&postcount=5

ngeronikolos
- 21st June 2007, 18:23
I did the following but nothing...
Please H E L P ME.I DO NOT UNDERSTAND!!!!


Why I have to change thE INC file?Why I never did it with 16f628?
We are talking for the INC file in the pbp folder?



;************************************************* ***************
;* 18F4550.INC *
;* *
;* By : Leonard Zerman, Jeff Schmoyer *
;* Notice : Copyright (c) 2006 microEngineering Labs, Inc. *
;* All Rights Reserved *
;* Date : 06/05/06 *
;* Version : 2.47 *
;* Notes : *
;************************************************* ***************
NOLIST
if def PM_USED
LIST
"Error: PM does not support this device. Use MPASM."
__CONFIG _CONFIG1H, _FOSC_INTOSC_XT_1H <-------- add it
NOLIST
else
LIST
LIST p = 18F4550, r = dec, w = -311, w = -230, f = inhx32
INCLUDE "P18F4550.INC" ; MPASM Header
__CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
__CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H
__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
__CONFIG _CONFIG3H, _PBADEN_OFF_3H
__CONFIG _CONFIG4L, _LVP_OFF_4L & _ICPRT_OFF_4L & _XINST_OFF_4L
NOLIST
endif
LIST
EEPROM_START EQU 0F00000h
BLOCK_SIZE EQU 32

Darrel Taylor
- 21st June 2007, 19:03
Oops, my fault. I should have been more complete with my descriptions.

The .INC file should look like this. The 2 red lines are commented out.

;************************************************* ***************
;* 18F4550.INC *
;* *
;* By : Leonard Zerman, Jeff Schmoyer *
;* Notice : Copyright (c) 2004 microEngineering Labs, Inc. *
;* All Rights Reserved *
;* Date : 12/31/04 *
;* Version : 2.46 *
;* Notes : *
;************************************************* ***************
NOLIST
ifdef PM_USED
LIST
"Error: PM does not support this device. Use MPASM."
NOLIST
else
LIST
LIST p = 18F4550, r = dec, w = -311, f = inhx32
INCLUDE "P18F4550.INC" ; MPASM Header
errorlevel -230
; __CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
; __CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H
__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H
__CONFIG _CONFIG3H, _PBADEN_OFF_3H
__CONFIG _CONFIG4L, _LVP_OFF_4L & _ICPRT_OFF_4L & _XINST_OFF_4L
NOLIST
endif
LIST
EEPROM_START EQU 0F00000h
BLOCK_SIZE EQU 32