Page 1 of 1

Serial Buffer Not Reading PIC 18F45K22

PostPosted: Wed Jul 02, 2014 5:02 pm
by SLTom992
I have SSP1 set up for serial date input in the Master Mode.

On the scope you can see the SCK1 clocks and you can see the SDI data at the input pin. When I read SSP1BUF there is nothing in the buffer register.

Code: Select all
    TRISC = 0b01110000;                    // SDO no output, SDI input, SCK output

    SSP1CON1 = 0b00100000;              // Enable SSP & SCK normally low
    SSP1STAT = 0b00000000;              // CKE = clock polarity 0->1


My scope doesn't have the ability to post screen dumps but the clocks are occurring during a solid high data input and the buffer reads 0x00. So this isn't a case of incorrect clock/data polarity.

Any ideas?

Re: Serial Buffer Not Reading PIC 18F45K22

PostPosted: Wed Jul 02, 2014 6:54 pm
by stumichaels
Can you take a picture of your scope with a digital camera or a smart phone and post it here? It would also be helpful if you showed your code.

Re: Serial Buffer Not Reading PIC 18F45K22

PostPosted: Wed Jul 02, 2014 8:14 pm
by SLTom992
I've taken pictures but cannot get them to download to this group.

Code: Select all
    (cause SCK group by SSP1BUF = 0x00;)
    if (SSP1IF) {                       // Buffer full
        measure = SSP1BUF;              // Also clears BF bit



SSP1BUF = 0x00 regardless of SDI

Re: Serial Buffer Not Reading PIC 18F45K22

PostPosted: Wed Jul 02, 2014 9:36 pm
by ric
I haven't checked your datasheet. Can the SPI pin acts as an analog input?
If yes, you MUST switch it to digital mode first.

Re: Serial Buffer Not Reading PIC 18F45K22

PostPosted: Wed Jul 02, 2014 10:14 pm
by SLTom992
That was a very good suggestion that I hadn't thought of. But I set it up properly in the first place:

Code: Select all
// Iniialize ADC for power level monitor

    ADCON0 = 0b00000101;                // ADC 1 Enabled
    ADCON1 = 0b00000000;                // V ref = power and ground
    ADCON2 = 0b00111110;                // (setup for clocks and read time)


The SDI port is AD16.

Re: Serial Buffer Not Reading PIC 18F45K22

PostPosted: Thu Jul 03, 2014 3:09 am
by Tom Maier
The "Configurator" plugin might also help youi with this problem. It supposedly not only has automatic setup of config bits, but can also insert driver software in to the code.

I'll be upgrading soon and will be trying this out. It also supports the newer pic24 chips.

http://www.microchip.com/pagehandler/en ... umentation

Re: Serial Buffer Not Reading PIC 18F45K22

PostPosted: Thu Jul 03, 2014 3:13 am
by ric
SLTom992 wrote:That was a very good suggestion that I hadn't thought of. But I set it up properly in the first place:

Code: Select all
// Iniialize ADC for power level monitor

    ADCON0 = 0b00000101;                // ADC 1 Enabled
    ADCON1 = 0b00000000;                // V ref = power and ground
    ADCON2 = 0b00111110;                // (setup for clocks and read time)


The SDI port is AD16.

You're not writing to the appropriate ANSEL register at all.
Ahhh, I thought this sounded familiar.
I didn't realise it was also you posting at http://www.microchip.com/forums/m805840.aspx#805853 where I just gave exactly the same answer.

Re: Serial Buffer Not Reading PIC 18F45K22

PostPosted: Thu Jul 03, 2014 3:16 am
by Tom Maier
I bet the "Configurator" wouldn't have made that mistake. :lol:

Have you tried that, Ric? I am always reluctant to upgrade, but that plugin has sparked my interest.