Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC32 XC32 - Bad Datasheet

Status
Not open for further replies.

AtomSoft

Well-Known Member
Hey im using the PIC32MX250F128D processor and noticed IFSx are switched:

Code:
extern volatile unsigned int        IFS0 __attribute__((section("sfrs")));
typedef union {
  struct {
    unsigned CTIF:1;
    unsigned CS0IF:1;
    unsigned CS1IF:1;
    unsigned INT0IF:1;
    unsigned T1IF:1;
    unsigned IC1EIF:1;
    unsigned IC1IF:1;
    unsigned OC1IF:1;
    unsigned INT1IF:1;
    unsigned T2IF:1;
    unsigned IC2EIF:1;
    unsigned IC2IF:1;
    unsigned OC2IF:1;
    unsigned INT2IF:1;
    unsigned T3IF:1;
    unsigned IC3EIF:1;
    unsigned IC3IF:1;
    unsigned OC3IF:1;
    unsigned INT3IF:1;
    unsigned T4IF:1;
    unsigned IC4EIF:1;
    unsigned IC4IF:1;
    unsigned OC4IF:1;
    unsigned INT4IF:1;
    unsigned T5IF:1;
    unsigned IC5EIF:1;
    unsigned IC5IF:1;
    unsigned OC5IF:1;
    unsigned AD1IF:1;
    unsigned FSCMIF:1;
    unsigned RTCCIF:1;
    unsigned FCEIF:1;
  };
  struct {
    unsigned w:32;
  };
} __IFS0bits_t;
extern volatile __IFS0bits_t IFS0bits __asm__ ("IFS0") __attribute__((section("sfrs")));
extern volatile unsigned int        IFS0CLR __attribute__((section("sfrs")));
extern volatile unsigned int        IFS0SET __attribute__((section("sfrs")));
extern volatile unsigned int        IFS0INV __attribute__((section("sfrs")));
extern volatile unsigned int        IFS1 __attribute__((section("sfrs")));
typedef union {
  struct {
    unsigned CMP1IF:1;
    unsigned CMP2IF:1;
    unsigned CMP3IF:1;
    unsigned USBIF:1;
    unsigned SPI1EIF:1;
    unsigned SPI1RXIF:1;
    unsigned SPI1TXIF:1;
    unsigned U1EIF:1;
    unsigned U1RXIF:1;
    unsigned U1TXIF:1;
    unsigned I2C1BIF:1;
    unsigned I2C1SIF:1;
    unsigned I2C1MIF:1;
    unsigned CNAIF:1;
    unsigned CNBIF:1;
    unsigned CNCIF:1;
    unsigned PMPIF:1;
    unsigned PMPEIF:1;
    unsigned SPI2EIF:1;
    unsigned SPI2RXIF:1;
    unsigned SPI2TXIF:1;
    unsigned U2EIF:1;
    unsigned U2RXIF:1;
    unsigned U2TXIF:1;
    unsigned I2C2BIF:1;
    unsigned I2C2SIF:1;
    unsigned I2C2MIF:1;
    unsigned CTMUIF:1;
    unsigned DMA0IF:1;
    unsigned DMA1IF:1;
    unsigned DMA2IF:1;
    unsigned DMA3IF:1;
  };
  struct {
    unsigned w:32;
  };
} __IFS1bits_t;
extern volatile __IFS1bits_t IFS1bits __asm__ ("IFS1") __attribute__((section("sfrs")));
extern volatile unsigned int        IFS1CLR __attribute__((section("sfrs")));
extern volatile unsigned int        IFS1SET __attribute__((section("sfrs")));
extern volatile unsigned int        IFS1INV __attribute__((section("sfrs")));

IFS0bits are supposed to be in IFS1 or at least thats what my datasheet states.

For instance : U1RXIF is in IFS1 when its supposed to be in IFS0

Or is this a DATASHEET MISTAKE?
ifs0.jpg

IFS1.jpg


Which is CORRECT?
How do i tell Microchip about this?
Why hasnt anyone else noticed this? (im sure im not the only guy using this MCU)

Im using XC32 1.31
 
I would suggest checking the errata page attached to the datasheet to make sure it's not an error there. I ran into that issue once with the ADCON register on the PIC18--the datasheet had everything inverted, and I think a couple of the bits mixed around. I checked the errata and there it was, corrected.

Unfortunately I have no experience with the PIC32, but hopefully this helps a bit.

Good luck,
Matt
 
Hmm. im sure its a XC32 error then. If no one really had this issue before and follow the datasheet with other compilers. Perhaps i should simply rename

IFS0bits ---> IFS1bits
and
IFS1bits ---> IFS0bits

Seems like that would fix it but am not sure. Dont want to ruin anything :)

.. Just noticed some bits are correct and some are not.. would have to rewrite it all as well just to make sure all bits match.. not hard work but something i shouldnt have to do :(
 
My Fix:

Replace lines 2775 to 2830

C:
extern volatile unsigned int        IFS0 __attribute__((section("sfrs")));
typedef union {
  struct {
    unsigned CTIF:1;
    unsigned CS0IF:1;
    unsigned CS1IF:1;
    unsigned INT0IF:1;
    unsigned T1IF:1;
    //unsigned IC1EIF:1;
    unsigned IC1IF:1;
    unsigned OC1IF:1;
    unsigned INT1IF:1;
    unsigned T2IF:1;
    //unsigned IC2EIF:1;
    unsigned IC2IF:1;
    unsigned OC2IF:1;
    unsigned INT2IF:1;
    unsigned T3IF:1;
    //unsigned IC3EIF:1;
    unsigned IC3IF:1;
    unsigned OC3IF:1;
    unsigned INT3IF:1;
    unsigned T4IF:1;
    //unsigned IC4EIF:1;
    unsigned IC4IF:1;
    unsigned OC4IF:1;
    unsigned INT4IF:1;
    unsigned T5IF:1;
    //unsigned IC5EIF:1;
    unsigned IC5IF:1;
    unsigned OC5IF:1;
    //unsigned AD1IF:1;
    //unsigned FSCMIF:1;
    //unsigned RTCCIF:1;
    //unsigned FCEIF:1;
    //ATOMSOFT FIX BELOW
    unsigned SPI1EIF:1;
    unsigned SPI1TXIF:1;
    unsigned SPI1RXIF:1;
    unsigned U1EIF:1;
    unsigned U1RXIF:1;
    unsigned U1TXIF:1;
    unsigned I2C1BIF:1;
    unsigned I2C1SIF:1;
    unsigned I2C1MIF:1;
    //END OF FIX
  };
  struct {
    unsigned w:32;
  };
} __IFS0bits_t;
extern volatile __IFS0bits_t IFS0bits __asm__ ("IFS0") __attribute__((section("sfrs")));
extern volatile unsigned int        IFS0CLR __attribute__((section("sfrs")));
extern volatile unsigned int        IFS0SET __attribute__((section("sfrs")));
extern volatile unsigned int        IFS0INV __attribute__((section("sfrs")));
extern volatile unsigned int        IFS1 __attribute__((section("sfrs")));
typedef union {
  struct {
    //AtomSoft Fix
    unsigned CNIF:1;
    unsigned AD1IF:1;
    unsigned PMPIF:1;
    unsigned CMP1IF:1;
    unsigned CMP2IF:1;
    unsigned SPI2EIF:1;
    unsigned SPI2TXIF:1;
    unsigned SPI2RXIF:1;
    unsigned U2EIF:1;
    unsigned U2RXIF:1;
    unsigned U2TXIF:1;
    unsigned I2C2BIF:1;
    unsigned I2C2SIF:1;
    unsigned I2C2MIF:1;
    unsigned FSCMIF:1;
    unsigned RTCCIF:1;
    unsigned DMA0IF:1;
    unsigned DMA1IF:1;
    unsigned DMA2IF:1;
    unsigned DMA3IF:1;
    unsigned USBIF:1;
    //unsigned CMP3IF:1;
    //unsigned SPI1EIF:1;
    //unsigned SPI1RXIF:1;
    //unsigned SPI1TXIF:1;
    //unsigned U1EIF:1;
    //unsigned U1RXIF:1;
    //unsigned U1TXIF:1;
    //unsigned I2C1BIF:1;
    //unsigned I2C1SIF:1;
    //unsigned I2C1MIF:1;
    //unsigned CNAIF:1;
    //unsigned CNBIF:1;
    //unsigned CNCIF:1;
    //unsigned PMPIF:1;
    //unsigned PMPEIF:1;
    //unsigned CTMUIF:1;

  };
  struct {
    unsigned w:32;
  };
} __IFS1bits_t;
extern volatile __IFS1bits_t IFS1bits __asm__ ("IFS1") __attribute__((section("sfrs")));
extern volatile unsigned int        IFS1CLR __attribute__((section("sfrs")));
extern volatile unsigned int        IFS1SET __attribute__((section("sfrs")));
extern volatile unsigned int        IFS1INV __attribute__((section("sfrs")));

C:
    //IFS1bits.U1RXIF = 0;  //BEFORE
    IFS0bits.U1RXIF = 0;    //AFTER
 
Last edited:
I guess i had some old documentation... hmm. google isnt your friend all the time... Got the newer version from Microchip and looks like it was correct. So was a datasheet flaw. Placing backup back :)
 
I guess i had some old documentation... hmm. google isnt your friend all the time... Got the newer version from Microchip and looks like it was correct. So was a datasheet flaw. Placing backup back :)

I've had that problem several times as well. When you get the datasheet for a PIC, it's critical that you get it directly from a link on the Microchip website. Usually the PDF that shows up directly on google has errors.

Glad you got it solved, Jason!
Matt
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top