Search code examples
cwarningsbuilt-inmicrochipmplab

MPLABX XC16 unable to resolve built-in identifier __builtin_dmaoffset


Im trying to do some basic ECAN sending using a dsPIC33FJ128GP802 and its built in DMA. The problem that im facing is that all the code examples in the documentation use the built in function __builtin_dmaoffset() to set the DMA onset buffer register DMA1STA but my compiler keeps telling me:

unable to resolve built-in identifier __builtin_dmaoffse

The code im using is:

#include <stdio.h>
#include <stdlib.h>
#include <xc.h>

#include <ADCConfig.h>
#include <ECANConfig.h>

int main(void) {

    oscConfig();

    initADC1();
    initDMA0();

    initECAN1();
    initDMA1();
    initDMA2();

    ... 

    unsigned int ecan1MsgBuf[32][8] __attribute__((space(dma)));
    DMA1STA=__builtin_dmaoffset(ecan1MsgBuf);

    ...
}

How do I get the built in function to work?


Solution

  • __builtin_dmaoffset() need to know the real address in order to calculate the DMA offset value. Try as follows-

    #define MSG_BUF_LENGTH 32
    
    int main(void) {
        ....
    
        unsigned int ecan1MsgBuf[32][8] __attribute__((space(dma),aligned(MSG_BUF_LENGTH*16)));
        DMA1STA=__builtin_dmaoffset(ecan1MsgBuf);
    
        ....
        }