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

    • Autonomous post-training loop placed 8th of 4,000 and then rewrote its own evaluation strategy. An autonomous AI system built by researchers at Amazon's A-EVO-Lab completed a full post-training run on a 30 billion parameter NVIDIA Nemotron model — with no human in the loop, across four rounds running over multiple weeks — and then did something its designers had not planned for: it detected that its own internal evaluation metric had become misleading and redesigned the search strategy it was using to improve itself. https://www.techtimes.com/articles/319123/20260626/nvidia-ai-trained-itself-30b-model-corrected-its-own-broken-metric-mid-run.htm
    • Grok Adult Content Tops 10 Billion Images Monthly More than half of all traffic flowing through Grok, Elon Musk's flagship AI product, now comes from users requesting pornographic images, explicit videos, and **** roleplay https://www.techtimes.com/articles/319142/20260626/grok-adult-content-tops-10-billion-images-monthly-xai-engineers-admit-csam-has-no-fix.htm
    • If Ford would stop hiring SUITS to run the company, and put CAR GUYS back in charge perhaps they could do better. Heck, the only CAR they produce today is the Mustang. Hey Ford! Not everyone needs/wants an overpriced SUV or pickup truck that is so tall you have to have a step ladder to get in and out of it.
    • Amazing how some will just jump all over something. Probably the same people that thought Musk was a "tech god" before he saddled up with "bad orange man". Before, they worshiped at his feet, including a lot of so called hollywood types. Now, because he fell off the plantation truck, they toss him under the bus.
  • Recent Achievements

    • One Year In
      bernmeister earned a badge
      One Year In
    • Week One Done
      Scoobystu earned a badge
      Week One Done
    • Week One Done
      tuben earned a badge
      Week One Done
    • First Post
      OffsetAbs earned a badge
      First Post
    • Reacting Well
      OffsetAbs earned a badge
      Reacting Well
  • Popular Contributors

    1. 1
      +primortal
      494
    2. 2
      +Edouard
      228
    3. 3
      PsYcHoKiLLa
      162
    4. 4
      Steven P.
      76
    5. 5
      FloatingFatMan
      71
  • Tell a friend

    Love Neowin? Tell a friend!