Moving to PIC24

Thread Starter

Robin Mitchell

Joined Oct 25, 2009
819
Hi all,

As silly as it sounds, I am moving to PIC24 and I am super excited to finally have a 16 bit micro in a DIP package that uses assembler similar to the PIC18 range. The PIC32 series would be great but it uses a totally different core and I don't have the time to learn MIPS at this point.

So here we go, multiple W registers, all 16 bits, faster internal cores, and 16KB of linear SRAM with no bank switching!
 

OBW0549

Joined Mar 2, 2015
3,566
Not silly at all. In recent years I've been using the PIC10F/PIC12F chips for really, REALLY small jobs, and the dsPIC30F/dsPIC33EP series for everything else. I do all my work in assembly language.

I've found that the 16-bit PICs are by far the easiest PICs to work with in assembly language; they just "make sense."
 

Thread Starter

Robin Mitchell

Joined Oct 25, 2009
819
It arrives in the next few days. IM SO EXCITED urrgghh!!!!

I am currently working on a TV video controller but realised that doing it in a PIC18 is too difficult for someone who is not a programmer first. On an 8bit micro I need to deal with lots of 16 bit operations and constantly worry about carry flags etc as well as loosing precious computing time. Hence why I FINALLY decided to move on!
 

OBW0549

Joined Mar 2, 2015
3,566
The 16-bit PICs are indeed easier to program; be aware, though, that there is a BIG learning curve you have to traverse before things smooth out:
  1. There is a HUGE amount of documentation to read through and absorb. Between the Programmer's Reference Manual, the PIC24F Family Reference Manual (which contains all the gory details about all of the on-chip peripherals), and the data sheet for whatever chip you plan on using, you've probably got somewhere between 2,000 and 3,000 pages of stuff to slog through. Crucial information isn't organized very well, and you can't skip ANY of it.
  2. Expect to be referring to the detailed instruction descriptions CONSTANTLY. Gone is that business about "only 35 simple instructions to learn" as with the "lesser" PICs; the 16-bit PICs have a very large instruction set, and there are a lot of intricate details. I imagine if a person spends 8 hours a day, five days a week, week after week doing assembler for these things he would eventually memorize most of the instructions in their various forms; but I've never been in that position so I've found I have to keep my .pdf of the Programmer's Reference Manual open at all times while I'm working.
  3. Finally, unlike with the 8-bit PICs, there are very few programming examples floating around the Web, so you are largely on your own.
Don't let me discourage you though; I guarantee you, the results will be worth the effort.
 

Thread Starter

Robin Mitchell

Joined Oct 25, 2009
819
@OBW0549

What IDE do you use to code the PIC24 in assembler?
For some reason, Microchip dropped support for coding the PIC24 in assembler in their MPLAB X ide and you can only use C. This is a big problem for me because their "lite" version is horribly bloated and I have some crucial timing routines.
 

OBW0549

Joined Mar 2, 2015
3,566
What IDE do you use to code the PIC24 in assembler?
I use MPLAB 8.92; I tried MPLAB X but found it to be a bloated monstrosity laden with features I really don't need. I'm sure it's fine for someone who does PIC programming frequently and can keep himself up near the top of the learning curve, but for an infrequent user like me its complexity is a real PITA since climbing back up the curve with every new project slows me down and generates annoyance.

The main drawback to MPLAB 8.92 is that it is frozen in time, and not updated to include support for the latest and greatest PIC chips. Thankfully, now that I'm retired and am back to being a "mere" hobbyist, that doesn't matter too much to me; though it certainly would be fun to play with some of their more recent MCUs, I'm content to stick with what I've got, all of which are supported in 8.92.

For some reason, Microchip dropped support for coding the PIC24 in assembler in their MPLAB X ide and you can only use C. This is a big problem for me because their "lite" version is horribly bloated and I have some crucial timing routines.
Have they really dropped all support for assembly language programming of the 16-bit parts? My understanding was that they've just made doing it awkward and non-obvious. You might want to go onto the Microchip forums and dig into this a bit further; I can't imagine there's not a solution.
 

Thread Starter

Robin Mitchell

Joined Oct 25, 2009
819
@OBW0549 @nsaspook

Thanks for the response guys and all the helpful links!
Yes, they have dropped assembly support for the 16 bit devices and despite having installed ASM30 the IDE will not allow you to select it during the project setup. The device I am using, the PIC24FJ256GA007 is not supported by 8.92 which is the version I have installed (I have both MPLABs). So I am stuck between a rock and a hard place.....unless I get MPLAB X V1.2 or lower (I believe)
 

nsaspook

Joined Aug 27, 2009
8,653
@OBW0549 @nsaspook

Thanks for the response guys and all the helpful links!
Yes, they have dropped assembly support for the 16 bit devices and despite having installed ASM30 the IDE will not allow you to select it during the project setup. The device I am using, the PIC24FJ256GA007 is not supported by 8.92 which is the version I have installed (I have both MPLABs). So I am stuck between a rock and a hard place.....unless I get MPLAB X V1.2 or lower (I believe)
It's not dropped, just made tricky to use with the xc16 tool chain as @OBW0549 said because ASM30 was EOL'd out of MPLAB X. The assembler inside the free compiler is exactly what ASM 30 used to be. It's still possible do to a pure 16bit ASM project with XC16 and MPLAB X.
http://ww1.microchip.com/downloads/en/DeviceDoc/50002106C.pdf
http://www.cs.unca.edu/brock/classes/Fall2013/csci255/labs/mplabxintroasm/index.html
 
Last edited:

OBW0549

Joined Mar 2, 2015
3,566
Following up from my post #5 above, a few more notes:
  • If you're accustomed to writing relocatable code for the 8-bit PICs using MPLINK, you won't notice much difference when going to the 16-bit parts. However, if you're used to coding in absolute mode (i.e., assigning variables to data memory using the EQU and CBLOCK directives and assigning code locations using ORG), be aware that (AFAIK) the 16-bit toolchain always has to include the linker. In that case, this will be somewhat of a paradigm shift and may cause a bit of head-scratching.
  • Good news: did you know that the entire 16-bit floating-point math library is available for use in assembly language? For free? Rejoice, it is!
  • Bad news: finding information on out how to use the math library (i.e., its calling conventions) is a major PITA. But it can be done.
If I think of anything else, I'll post.
 
Top