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

MCP23S08 returns 0x00 intermittingly

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



Joined: 07 Feb 2008
Posts: 186

View user's profile Send private message

MCP23S08 returns 0x00 intermittingly
PostPosted: Mon Jan 12, 2026 10:22 am     Reply with quote

Has anyone had an issue with a Microchip MCP23S08 port expander used as an input device, returning a 0x00 intermittingly.

Using pretty standard read code:

Code:

//=============================================================================
int8 ReadFrom_Thermo_Exp(void)
{
int8  received_Therm_data;
int8  dummy;

output_low(THERM_CS);
delay_us(50);
dummy= spi_xfer(CONTROL_REG_VAL_Read);           
dummy= spi_xfer(GPIO_CONFIG_VAL);                           
received_Therm_data = spi_xfer(0);
delay_us(50);
output_high(THERM_CS);
delay_us(50);

return received_Therm_data;
}



Sampling at as slow as one second rate. SPI set up:
Code:

#use spi(MASTER, SPI1, BITS=8, BAUD=100000, MODE=0)


0x00 returned at random times from every 15 to every 100 reads.

Any help is appreciated!
Ttelmah



Joined: 11 Mar 2010
Posts: 20018

View user's profile Send private message

PostPosted: Mon Jan 12, 2026 10:47 am     Reply with quote

What are your defined values for
CONTROL_REG_VAL_Read
and
GPIO_CONFIG_VAL
?

What else do you do on the SPI bus between the commands?.
What PIC?.
What compiler version.

Honestly an intermittent behaviour suggests a hardware glitch.
temtronic



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

View user's profile Send private message

PostPosted: Mon Jan 12, 2026 6:47 pm     Reply with quote

just thinking out load here but...

I was thinking maybe no pullups on the inputs, might cause a '0' or two, but ALL '0's does seem 'weird'.

Have you tested with a known pattern as the inputs ( ie HARD wired 1s and 0s ).
JerryR



Joined: 07 Feb 2008
Posts: 186

View user's profile Send private message

PostPosted: Tue Jan 13, 2026 8:20 am     Reply with quote

Solved

Well, there was no issue digitally. Non-synchronous noise on input on MCP23S08 actually was triggering a 0x00 output.

Thanks so much for your consideration and sanity check.

Best regards
temtronic



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

View user's profile Send private message

PostPosted: Tue Jan 13, 2026 10:41 am     Reply with quote

Nice to hear you FOUND the cause ! It took me 2 MONTHS to discover 'crosstalk' on a main span of Bell telephone cables was causing 'my' problem, ONLY between 2 and 3 AM, Sunday mornings.
Ttelmah



Joined: 11 Mar 2010
Posts: 20018

View user's profile Send private message

PostPosted: Wed Jan 14, 2026 1:54 am     Reply with quote

Well done. 'Glitch' was exactly right!. It sounded like that..... Very Happy
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