CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

SPI Problem on port from 16f877 to 16f887

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
hucker



Joined: 25 Jan 2017
Posts: 7

View user's profile Send private message

SPI Problem on port from 16f877 to 16f887
PostPosted: Thu Feb 16, 2017 2:10 pm     Reply with quote

I am porting a project when we did a board spin and am having issues getting the SPI code to work correctly. The legacy 877 code has been stable and running for many...many... years.

We have an SPI bus with two devices (like before), a programmable gain amplifier/MUX (MCP6S28) and an A/D (MCP3208).

The new layout is the same as the old layout in terms of pins on the 887 and the two SPI devices.

When I watch the signals on the scope I see the command go out on the SPI, I see the PGA/Mux receive the command and a new analog voltage show up at the AD, I see the chip selects change and the AD clocks out the data however the spi_read always returns 0x00.

I'm using this legacy setup (that has worked for years):

setup_spi(SPI_MASTER | SPI_L_TO_H | SPI_CLK_DIV_16 | SPI_XMIT_L_TO_H);

and the following code to read the data (again legacy):

Code:

int32 get_ad_value(int gain_ind,int channel)
{
     unsigned int low,high;
     int16 value;

     set_pga(gain_ind,channel);
     output_low(MONITOR_AD_SPI_CS);

     // Always read channel 0
     spi_read(0x6);
     high = spi_read(0) & 0xf;
     low  = spi_read(0);

     // commands to send
    output_high(MONITOR_AD_SPI_CS);

     value = make16(high,low);
     return value;
}


I have looked in the debugger and see that high/low both have 0x00 in them.

Apparently I have clock and MOSI setup correctly because I am seeing the two parts change state as expected, what I don't ever see is the PIC reading a number from the SPI.

I am now thinking there is some other setup or errata or other piece of information I'm missing.
temtronic



Joined: 01 Jul 2010
Posts: 9221
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Feb 16, 2017 2:20 pm     Reply with quote

have you tried an 877 in place of the 887 in the new board?
hucker



Joined: 25 Jan 2017
Posts: 7

View user's profile Send private message

PostPosted: Thu Feb 16, 2017 2:33 pm     Reply with quote

Nope... I probably need to order one but I have not tried that.
temtronic



Joined: 01 Jul 2010
Posts: 9221
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Feb 16, 2017 2:47 pm     Reply with quote

I got 2 tubes full of them, 20 years old...sigh...
Be sure to install a socket so you can swap the PICs out.

Jay
hucker



Joined: 25 Jan 2017
Posts: 7

View user's profile Send private message

PostPosted: Thu Feb 16, 2017 5:56 pm     Reply with quote

Rework had bad solder joint on the backside of the test point. Data looks good on testpoint...but not on MISO pin on 887. Argh
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group