Hot!MCC BUG : PIC18F26K42 SPI Peripheral

Author
delamitry
New Member
  • Total Posts : 6
  • Reward points : 0
  • Joined: 2016/09/06 10:58:40
  • Location: 0
  • Status: offline
2018/01/09 22:18:45 (permalink)
0

MCC BUG : PIC18F26K42 SPI Peripheral

MCC version: v3.45.1
MPLAB X version: v4.05
OS: WIN 10 64bit
Area: Generated Code
Device: PIC18F26K42
Peripheral: SPI
 
The generated initialization function is always empty regardless of the settings made in the SPI UI (easy setup or registers)
 
void SPI1_Initialize(void)
{
    // Set the SPI1 module to the options selected in the User Interface
}

 
I can confirm that after manually adding the registers values myself, SPI seems to function as intended.
Thanks for your attention!
Greg
#1

4 Replies Related Threads

    mbrowning
    Just a Member
    • Total Posts : 981
    • Reward points : 0
    • Joined: 2005/03/16 14:32:56
    • Location: Melbourne, FL
    • Status: offline
    Re: MCC BUG : PIC18F26K42 SPI Peripheral 2018/01/10 06:10:25 (permalink)
    0
    You could let Microchip know by submitting a support ticket

    Can't remember. I've slept since then - Mark
    #2
    tsoof
    New Member
    • Total Posts : 5
    • Reward points : 0
    • Joined: 2016/10/30 07:41:21
    • Location: 0
    • Status: offline
    Re: MCC BUG : PIC18F26K42 SPI Peripheral 2018/01/11 06:34:52 (permalink)
    0
    Hello,
    I am having the same problem, and was wondering if you could help.
     
    I created a project with PIC18F26k42 and generated the code using MCC generator.
    Timers are working fine, BUT the SPI doesn't work,
    I can't see ANY signal in the SCK pin with an oscilloscope.
     
    It is as you said, the initialization is empty,
    so I tried to implement my own initialization but it is still NOT working..
    Could you provide your initialization code? and also did you modify anything else from the generated MCC files?
     
    Here is my initialization:
    void SPI1_Initialize(void)
    {
        SPI1CON0bits.EN = 0; // Disable
        
        SPI1CON0bits.MST = 1; // MASTER
        SPI1CON0bits.BMODE = 0;
        
        SPI1CON1bits.SMP = 0;
        SPI1CON1bits.CKE = 0;
        SPI1CON1bits.CKP = 1;
        
        // Write only mode
        SPI1CON2bits.TXR = 1;
        SPI1CON2bits.RXR = 0;
        
        SPI1CON0bits.EN = 1; // Enable
    }

     
    When I use SPI1_Exchange8bit it doesn't trigger any SCK signal,
    Also it gets stuck so I modified it:
    uint8_t SPI1_Exchange8bit(uint8_t data)
    {
        //One byte transfer count
        SPI1TCNTL = 1;
        SPI1TXB = data;
        
        while (SPI1INTFbits.SRMTIF == 0);

        return (SPI1RXB);
    }

     
    Thanks.
    #3
    delamitry
    New Member
    • Total Posts : 6
    • Reward points : 0
    • Joined: 2016/09/06 10:58:40
    • Location: 0
    • Status: offline
    Re: MCC BUG : PIC18F26K42 SPI Peripheral 2018/01/13 17:23:59 (permalink)
    0
    These are the initialization settings I used. Please note that I'm setting the spi clock to the timer 2 peripheral.
    You can shortcut figuring out the bits to set by using the registers tab in MCC, setting the appropriate values, then swiping the hex value from the ui. (see attached image)
     


    void SPI1_Initialize(void)

    {

    // Set the SPI1 module to the options selected in the User Interface

    SPI1CLK = 0x5;

    SPI1CON0 = 0x83;

    SPI1CON1 = 0x0;

    SPI1CON2 = 0x2;

    }



     

    Attached Image(s)

    #4
    tsoofamdar
    New Member
    • Total Posts : 4
    • Reward points : 0
    • Joined: 2018/01/10 23:11:19
    • Location: 0
    • Status: offline
    Re: MCC BUG : PIC18F26K42 SPI Peripheral 2018/01/14 00:34:03 (permalink)
    0
    Thanks for the reply,
    Well I tried to work around the initialization as you mentioned, but still no luck...
    I still don't get any SCK signal.
     
    If i check the SOSIF (the Slave Select interrupt flag) which should trigger the start of the transmission , it stays low, which I understand, is indicating that there is no start of transmission.
    I am starting to run out of ideas...
     
    Maybe if you could provide all the necessary code for the SPI module, that would give me some idea of what could be my problem.
    At least the SPI1_Exchange8bit() function, the PINs and PPS initialization.
    That would really help!
     
    Thanks in advance.
    #5
    Jump to:
    © 2018 APG vNext Commercial Version 4.5