Troubles using EEPROM SPI ports

A small embedded server. Get one for $40, including worldwide shipping.

Troubles using EEPROM SPI ports

Postby selfservice » Tue Dec 27, 2011 1:52 pm

Hi, i'm using EEPROM SPI expansion port to control some shift registers.
I've no problem in using output (driving MOSI pin via spi) but when i try to read a shift register looks like the dspic is driving low the MISO line. The CS line is high so the eeprom is in three state...

I've tried to force MISO pin as input and i can get some data from the registers but with some bits missing (maybe due to spi module misconfiguration)

Anyone had to deal with the same problem before?

Bye, Stefano
selfservice
Newbie
Newbie
 
Posts: 15
Joined: Tue Apr 20, 2010 9:32 am

Re: Troubles using EEPROM SPI ports

Postby ian » Tue Dec 27, 2011 2:33 pm

Hi Stefano,

Will you please post the setup and use code?
User avatar
ian
Crew
Crew
 
Posts: 10803
Joined: Mon Jul 06, 2009 6:14 am

Re: Troubles using EEPROM SPI ports

Postby selfservice » Wed Dec 28, 2011 1:04 pm

Hi, i've solved the issue, there was a trouble in code.
By setting both MISO and MOSI pins as input the thing is working (both eeprom and shift registers on the same bus).
Of course this is not a final solution and i'm trying to figure it out what is really happening, because original code is setting up TRIS registers correctly but for some reason when SPI is disabled dspic is driving MISO line low.
selfservice
Newbie
Newbie
 
Posts: 15
Joined: Tue Apr 20, 2010 9:32 am

Re: Troubles using EEPROM SPI ports

Postby selfservice » Thu Dec 29, 2011 8:42 am

Ok, i've figured out all.
In main.c the original code setup the MISO pin on PORTC8 wich is correct with the schematic.
Then on the HardwareProfile.h the TRISC8 is assigned to EEPROM_SDO_TRIS wich is set to zero in SPIEEPROM.c !!
This is because microchip stack is ambiguos in that definitions and can easily led to errors.
I suggest to swap EEPROM_SDI and EEPROM_SDO to fix this problem!
selfservice
Newbie
Newbie
 
Posts: 15
Joined: Tue Apr 20, 2010 9:32 am


Return to Web platform