5
\$\begingroup\$

Pic18fxxx family has a lot advantages and improvements from the pic16fxxx family of microcontrollers. What is the particular feature that make them better for C programming than the pic16fxxx devices?

asked Mar 15, 2013 at 20:54
\$\endgroup\$
5
  • 3
    \$\begingroup\$ What makes you think they're ideal for C? I would argue that any PIC24 device is far more 'ideal' than any PIC16/18 device from an architectural standpoint (more registers, more RAM...), and any PIC32 is far more 'ideal' than a PIC24 by nature of it's MIPS architecture... \$\endgroup\$ Commented Mar 15, 2013 at 21:24
  • \$\begingroup\$ Sorry, i write it wrong. Ideal compared to pic14f devices not to others. \$\endgroup\$ Commented Mar 15, 2013 at 21:38
  • \$\begingroup\$ PIC14F? That family doesn't exist, does it? \$\endgroup\$ Commented Mar 16, 2013 at 8:10
  • \$\begingroup\$ I mean pic16fxxx. Mistake upon mistake! \$\endgroup\$ Commented Mar 16, 2013 at 10:18
  • 1
    \$\begingroup\$ Actually there was a PIC 14 once, but now along with the PIC 17 it "never existed". \$\endgroup\$ Commented Mar 16, 2013 at 13:16

3 Answers 3

8
\$\begingroup\$

I don't know about "ideal for". That's a marketing term that has no place in a learned discussion.

However, one big advantage of the PIC 18 architecture versus the original PIC 16 architecture, especially related to compilers, is that it is possible to implement a software data stack on a PIC 18 with single instructions for PUSH and POP. The PIC 18 also has a deeper call stack, 32 versus 8, which can help when a compiler implicitly calls subroutines. The PLUSW indirect addressing mode is probably something a compiler would make more frequent use of than a human programmer.

The PIC 18 also has other advantages that are useful both for compilers and human programmers, like 3 hardware pointers instead of one, auto inc/dec indirect addressing modes, a 8x8 into 16 hardware multiplier, add with carry, and subtract with borrow, and a few other niceties.

answered Mar 15, 2013 at 21:25
\$\endgroup\$
1
  • 2
    \$\begingroup\$ You are right, i changed to 'better' than 'ideal'. \$\endgroup\$ Commented Mar 15, 2013 at 21:44
2
\$\begingroup\$

Some C compilers store local variables on a hardware or software stack. When code enters a subroutine, the size of its local variables is added to or subtracted from a register which is used as a stack/frame pointer. When the "enhanced instruction set" is enabled, PIC18Fxx instructions can access the first ~96 bytes following the frame-pointer address directly. This is ALMOST a really good feature. It would have been a really good feature if e.g. the processor had made 15 bytes of the unbanked address space map to addresses 1-15 bytes above FSR2, and 7 bytes map to addresses 1-7 bytes above the each of the other FSR registers, while leaving most of the unbanked space as unbanked RAM. Unfortunately, notwithstanding the fact that most functions won't even have eight bytes of local storage (much less 16), giving up 96 addresses to handle offsets 0-95 above FSR2 is absurdly wasteful.

Note that some other C compiler systems assign fixed addresses for local variables; such systems determine at link time which functions cannot be "live" simultaneously, and can allocate the variables for such functions at the same addresses. Provided code does is not called in re-entrant fashion, this approach can be just as efficient (sometimes more so) than using a stack; it does, however, not work with re-entrant routines.

answered Mar 15, 2013 at 21:27
\$\endgroup\$
1
\$\begingroup\$

You can ask google well about the lot of comparison between PIC16F vs PIC18F.

Coming to you question Why pic18fxxx microcontrollers are better for C language?

PIC18F or any other micro-controller that can be assumed better for C language are those micro controllers that supports such assembly instructions by default that can help C compilers to make efficient and optimized hex files.

One major example of these kind of instructions can be MATH related instructions

XC8 compiler supports extended instruction set which is specially helps C compilers to generate we optimized binary file.

answered Mar 16, 2013 at 3:08
\$\endgroup\$
3
  • \$\begingroup\$ This is a non-answer. The OP already knows that a PIC 18 supports C better, but asked how specifically it does that. \$\endgroup\$ Commented Mar 16, 2013 at 13:18
  • \$\begingroup\$ I mentioned already that by supporting special power full instruction set that pic16f does not have \$\endgroup\$ Commented Mar 16, 2013 at 19:50
  • 1
    \$\begingroup\$ Right, but that is obvious and was already known. The OP is already aware that the PIC 18 has "a lot advantages and improvements from the pic16fxxx". Without explaining what specifically, like particular instructions and the like, you think aids compilers, this is no answer at all. \$\endgroup\$ Commented Mar 16, 2013 at 22:16

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.