Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Pic16f to pic18f ?

Status
Not open for further replies.

pixman

Member
Hi

I HAVE ONLY WORKED WITH PIC16F CHIPS. AND USE ASSEMBLE.
CAN THE PIC18F BE PROGRAMMED WITH ASSEMBLE AND WHAT ARE THE ADVANTAGES OF
USING A 18F OVER 16F FOR THE HOBBIEST. I WOULD LIKE TO LEARN C BUT HAVE KNOW IDEA WERE TO START.

DAVID
 
Hi

I HAVE ONLY WORKED WITH PIC16F CHIPS. AND USE ASSEMBLE.
CAN THE PIC18F BE PROGRAMMED WITH ASSEMBLE AND WHAT ARE THE ADVANTAGES OF
USING A 18F OVER 16F FOR THE HOBBIEST. I WOULD LIKE TO LEARN C BUT HAVE KNOW IDEA WERE TO START.

DAVID

hi David,
You can program the 18F series in assembler in the same way as the 16F series.
There is a free download from Microchip Technology Inc. is a Leading Provider of Microcontroller and Analog Semiconductors, providing low-risk product development, lower total system cost and faster time to market for thousands of diverse customer applications worldwide. of MPLAB IDE Vxxx assembler, also I believe there is a 'student' version of their 'C' compiler.

The 18F has many extra features that are not included in the 16F, one example is the USB peripheral.

Are you experienced in the 16F assembly.??
 
I am not a expert. I learn things as i need to know. I play around with pics to keep my self busy and mind active.
 
I am not a expert. I learn things as i need to know. I play around with pics to keep my self busy and mind active.

OK,
Look at Nigel's 16F tutorials link, its near my signature on this post.

Also Bill's link has lots of info.
 
Last edited:
I have done all nigels tutorials and they are a good place to start for a beginner. I will have a look at bills link.
 
Hi,

Well I found the 18Fs so much easier to use with assembler than the 16F chips,
No more problems with paging and banking instructions and with large ram banks life is easy.

Most of your 16F code will port over very easily, just complie it and the errors are obvious, mostly a case for removing the banking instructions.

For a general purpose chips look at the 18F1320, 2520, 4520, 4620 range.
There are USB chips like the 18F2550 /4550 but you really need C to use the USB features, though you can also use them with assembler for non USB work.

Look at the 18F .template files in Mpasm which show how to get started as the interrupt system is on two levels.
 
Thanks. I hate the paging with 16f, it gets confusing. I have recently bought a pickit 3 debug express and it comes with a 18f45k20 on the board, the only problem with this is that all the tutorials are for c. I will look at the data sheet and play around with it in assemble.

Is setting up the config the same as with 16f series.
 
Another question is, i have the book 'c for dummies'. If i learn this will i be able to us what i have learnt for programming pics.
 
18F has better memory!! and it can multiply 8 bit * 8 bit = 16 bit in one instruction.
 
a 18f45k20 on the board...

Is setting up the config the same as with 16f series.
No. 18F's have a LOT more config controls, spread over multiple bytes. 99% of these you don't have to touch for most programs. It's not much more difficult than a 16F - just different. Once you figure out the four or five controls you use on most programs you just set those on every program. The rest work fine at default settings.

Here's a typical 18F config in C (18F2523):
Code:
#pragma DATA    _CONFIG1H, _OSC_HS_1H
#pragma DATA    _CONFIG2H, _WDT_OFF_2H
#pragma DATA    _CONFIG3H, _MCLRE_ON_3H
#pragma DATA    _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
As you can see, the five things I need to set are in four different config bytes.

And yes, 18Fs are much nicer to program in asm than 16Fs. Takes fewer lines of code to do the same thing. Before I switched almost 100% to C, I used to program them all in asm.
 
Last edited:
I played around last night an got a 18f45k20 to 'hello world' and did a led chaser on portd. I did notice the some of the commands are different.
RLF is now RLCF and RRF is now RRCF. I will now try and figure out the ADC and INTERUPT.
The config setting for the 18f45k20 is involved but reading the data sheet carefully it makes sense.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top