• 0

PIC18F4550, MPLABX and XC8 - Am I missing something?


Question

I've just had to switch from a dsPIC to a PIC18F4550 due to data size, and I think I might have found a problem...

Using MPLABX IDE v1.85 and XC8 v1.20; It's telling me that my use of TRISC is wrong, and insists the only parts of TRISC that exist are TRISCbits.: TRISC0, TRISC1, TRISC2, TRISC6, TRISC7 I.e. no 3, 4, or 5... All of which are present in the datasheet.

I'm not sure if I'm doing something wrong or what, anyone else got a similar issue?

Nevermind, fixed that, you use to use PORTC not LATC... Pretty stupid seeing as they're mapped to the same address...

 

Also how the hell do you enable the extended CPU instructions? You enable it using the configuration bits but when you try and build it gives an error saying the program wasn't built with them! There's nothing in the whole of project settings that I can see to enable it either.

Also anyone else having problems with neowin removing ALL formatting and making just a wad of text when they post?

6 answers to this question

Recommended Posts

  • 0

Check the datasheet again. Those TRISC bits don't exist. You can't clear them. Those pins cannot be used as a digital output, since they're muxed with the USB module.

 

Also, the PIC18F4550 is a paltry 32KB. The largest dsPICs are 512K. (I greatly prefer the dsPIC33F and PIC24F to the 18F series, myself)

 

>Also how the hell do you enable the extended CPU instructions?

 

I don't think XC8 supports them. You'll have to use C18. (Not that they buy you much)

  • 0

Nevermind, fixed that, you use to use PORTC not LATC... Pretty stupid seeing as they're mapped to the same address...

 

PORTx and LATx absolutely are not the same.

 

The PORTx is the port itself. LATx isn't. Rather, it's the output latch.

 

In general, the rule of thumb is as follows: Read from the PORT, Write to the LAT.

 

This way, read-modify-write operations are always guaranteed to perform as expected.

  • 0

I've got 18F4520s, 18F4550s and ds40F4014s lying around, the DSPIC has sporatic pins of ports scattered and doesn't have 8 pins of a port in a row anywhere that you can use (only RB is like that and 2 pins are reserved for programming/debugging).

Ah noted PORT and LAT aren't the same, sure I read something about them being the same, maybe it was an 16Fx manual.

 

"Those TRISC bits don't exist. You can't clear them. Those pins cannot be used as a digital output, since they're muxed with the USB module"

RC3 doesn't exist at all, true, but the diagram wrongly indicates you can use RC4 and RC5 as inputs and outputs, it's not until you read the actual I/O blurb it tells you that you can't.

 

Yes looks like xc8 doesn't support the extended instructions :/

  • 0

The diagram is perfectly correct. When operating as D+ and D-, they're bidirectional dataports. Otherwise, how could it communicate over USB? What they aren't is full-fledged GPIOs. They have limits, which the datasheet goes into. 

 

How often do you need to access an 8-bit wide databus in one instruction? Who cares that the pins are all over the place? Even so, the speed gains of using a better chip like something out a PIC24 or dsPIC33F make up for it.

  • 0

ds40F4014s 

 

There is no ds40 series.

 

If you want a chip suggestion that works in a through hole package, the dsPIC33FJ128GP802 is one of the best. Virtually all of my prototypes start with that chip before I nail down the specific one in that family.

 

No USB, though. I very rarely have projects that need USB these days. I have a PIC24FJ256DA206 project with it, though.

  • 0

30F4013 even.

I don't need USB, just the 18F4520 I have has a broken pin.

Project isn't going that great anyway, got an 8x8 RGB LED matrix and it's not displaying correctly at all unless I individually step through the whole function so I might just shelve it.

This topic is now closed to further replies.