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.
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.
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.
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.
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.