Serial Buffer Not Reading PIC 18F45K22

(instructions, reset, WDT, specifications...) PIC17Cxx, PIC18Fxxx

Serial Buffer Not Reading PIC 18F45K22

Postby SLTom992 » Wed Jul 02, 2014 5:02 pm

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?
SLTom992
 
Posts: 58
Joined: Tue Jun 10, 2014 8:59 pm
PIC experience: Professional 1+ years with MCHP products

Re: Serial Buffer Not Reading PIC 18F45K22

Postby stumichaels » Wed Jul 02, 2014 6:54 pm

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.
User avatar
stumichaels
 
Posts: 4
Joined: Fri May 30, 2014 7:25 pm
PIC experience: Professional 5+ years with MCHP products

Re: Serial Buffer Not Reading PIC 18F45K22

Postby SLTom992 » Wed Jul 02, 2014 8:14 pm

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
SLTom992
 
Posts: 58
Joined: Tue Jun 10, 2014 8:59 pm
PIC experience: Professional 1+ years with MCHP products

Re: Serial Buffer Not Reading PIC 18F45K22

Postby ric » Wed Jul 02, 2014 9:36 pm

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.
Latest test project, an LED matrix display made from one reel of addressable LEDs. here
User avatar
ric
Verified identity
 
Posts: 659
Joined: Sat May 24, 2014 2:35 pm
Location: Melbourne, Australia
PIC experience: Professional 5+ years with MCHP products

Re: Serial Buffer Not Reading PIC 18F45K22

Postby SLTom992 » Wed Jul 02, 2014 10:14 pm

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.
SLTom992
 
Posts: 58
Joined: Tue Jun 10, 2014 8:59 pm
PIC experience: Professional 1+ years with MCHP products

Re: Serial Buffer Not Reading PIC 18F45K22

Postby Tom Maier » Thu Jul 03, 2014 3:09 am

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
User avatar
Tom Maier
Verified identity
 
Posts: 179
Joined: Mon May 26, 2014 2:37 pm
PIC experience: Professional 5+ years with MCHP products

Re: Serial Buffer Not Reading PIC 18F45K22

Postby ric » Thu Jul 03, 2014 3:13 am

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.
Latest test project, an LED matrix display made from one reel of addressable LEDs. here
User avatar
ric
Verified identity
 
Posts: 659
Joined: Sat May 24, 2014 2:35 pm
Location: Melbourne, Australia
PIC experience: Professional 5+ years with MCHP products

Re: Serial Buffer Not Reading PIC 18F45K22

Postby Tom Maier » Thu Jul 03, 2014 3:16 am

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.
User avatar
Tom Maier
Verified identity
 
Posts: 179
Joined: Mon May 26, 2014 2:37 pm
PIC experience: Professional 5+ years with MCHP products


Return to 16-Bit Core

Who is online

Users browsing this forum: No registered users and 4 guests

cron