| View previous topic :: View next topic |
| Author |
Message |
JerryR
Joined: 07 Feb 2008 Posts: 186
|
| MCP23S08 returns 0x00 intermittingly |
Posted: Mon Jan 12, 2026 10:22 am |
|
|
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
|
|
Posted: Mon Jan 12, 2026 10:47 am |
|
|
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
|
|
Posted: Mon Jan 12, 2026 6:47 pm |
|
|
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
|
|
Posted: Tue Jan 13, 2026 8:20 am |
|
|
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
|
|
Posted: Tue Jan 13, 2026 10:41 am |
|
|
| 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
|
|
Posted: Wed Jan 14, 2026 1:54 am |
|
|
Well done. 'Glitch' was exactly right!. It sounded like that.....  |
|
 |
|