• AVR Freaks

Hot!SPI Clock: Easy Setup Does Not Match Measured. Why?

Author
joelindo
New Member
  • Total Posts : 6
  • Reward points : 0
  • Joined: 2018/11/05 18:13:04
  • Location: 0
  • Status: offline
2018/11/07 10:50:55 (permalink)
0

SPI Clock: Easy Setup Does Not Match Measured. Why?

PIC16F18855, MPLAB X IDE V5.00, MCC V3, PICKit 4
Using Easy Setup, SPI Master, SPI clock source = FOS/4, other settings seem not to make a difference with respect to clock.
Easy Setup says SPI Clock is 1.9375 KHz, however, clock measured by scope on pin 14 is 250KHz.
What am I doing wrong?
Joe
post edited by joelindo - 2018/11/07 10:52:20
#1

5 Replies Related Threads

    du00000001
    Just Some Member
    • Total Posts : 2677
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: SPI Clock: Easy Setup Does Not Match Measured. Why? 2018/11/07 11:08:09 (permalink)
    +1 (1)
    Wrong processor clock config? Due to whatever reason ...
    If FOsc/4 holds, FOsc would be 1 MHz, while Easy Setup seems to assume 7.75 MHz (BTW: a quite unusual frequency).

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #2
    joelindo
    New Member
    • Total Posts : 6
    • Reward points : 0
    • Joined: 2018/11/05 18:13:04
    • Location: 0
    • Status: offline
    Re: SPI Clock: Easy Setup Does Not Match Measured. Why? 2018/11/07 11:25:23 (permalink)
    0
    Yes, it is 1MHz and Easy Setup does assume 7.75MHz. . . I'm a very old guy, 70, who is trying to learn this new tech. I'm from the wire-wrap days. This is my first attempt. Can you recommend a learning environment?
    #3
    Jim Nickerson
    User 452
    • Total Posts : 5940
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: offline
    Re: SPI Clock: Easy Setup Does Not Match Measured. Why? 2018/11/07 11:35:31 (permalink)
    +1 (1)
    With a new processor I usually start with one of the development boards that comes preloaded with demo software so everything works right out of the box.
    Before making any experiments/changes I back up / copy the original code in the part so I can get back to where I started.
    #4
    du00000001
    Just Some Member
    • Total Posts : 2677
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: SPI Clock: Easy Setup Does Not Match Measured. Why? 2018/11/07 12:36:42 (permalink)
    0
    Re: learning environment
    I currently cannot run MCC (still on Win XP  :) ).
     
    Thus, when I have to set up a new microcontroller (I'm working with an ever-increasing number of different PIC16s and dsPICs - usually "the perfect fit" for a certain task), I check whether some setup for this controller is available on MPLAB Xpress
    https://www.microchip.com/mplab/mplab-xpress ). While a such setup might require some modifications (done manually - datasheet opened), I usually get around the first intricacies. (Unfortunately, MPLAB Xpress does not supply such a downloadable setuo for each and every derivative  :( )

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #5
    joelindo
    New Member
    • Total Posts : 6
    • Reward points : 0
    • Joined: 2018/11/05 18:13:04
    • Location: 0
    • Status: offline
    Re: SPI Clock: Easy Setup Does Not Match Measured. Why? 2018/11/24 17:28:50 (permalink)
    0
    New symptoms: I was able to program two 16F18855 chips, one as master and one as slave. The slave read the SPI connection and correctly turned an LED on and off. The master monitored a switch and sent that info to the slave for operating the LED, and it all worked. However, when I try to change settings in SPI Easy Setup, nothing changes. The clock remains "idle low, active high," and the rate remains at 250KHz.
     
    void main(void)
    {
        SYSTEM_Initialize();

        while (1)
        {
            PORTCbits.RC2 = 0;//select slave
            if(PORTAbits.RA5 == 1) {//get push button value
                PORTAbits.RA0 = 0;//if pushed turn on the LED
                //PORTCbits.RC2 = 0;//select slave
                SPI1_Exchange8bit(255);//send the byte 0xFF
                __delay_ms(1);//wait for 1 millisecond to avoid spamming the slave
            } else {
                PORTAbits.RA0 = 1;//if not pushed turn off the LED
                //PORTCbits.RC2 = 0;//select slave
                SPI1_Exchange8bit(0);//send the byte 0x00
                __delay_ms(1);//wait for 1 millisecond to avoid spamming the slave
            }
            PORTCbits.RC2 = 1;//deselect slave
        }
    }
    #6
    Jump to:
    © 2019 APG vNext Commercial Version 4.5