 |
 |
| View previous topic :: View next topic |
| Author |
Message |
logical
Joined: 21 Dec 2009 Posts: 57 Location: SouthPort, UK
|
|
Posted: Thu Feb 04, 2010 5:45 pm |
|
|
Back again,
Tried as you mentioned with another value other than 0xff, same difference, scrapped the project and did it from scratch, same result
After playing around with just about everything, the only thing that makes a difference is setting the divide by 64 for the SPI Clock, now I get data and 8 clocks but that is the only way to get it to work, tried it on the other SPI port and exactly the same.
The code I used to test with is: | Code: | void main()
{
setup_spi(SPI_MASTER | SPI_L_TO_H | SPI_CLK_DIV_4);
setup_spi2(SPI_MASTER | SPI_L_TO_H | SPI_CLK_DIV_64);
#pin_select SCK2OUT=PIN_B2
#pin_select SDO2=PIN_B3
#pin_select SDI2=PIN_C0
setup_wdt(WDT_OFF);
setup_timer1(TMR_DISABLED);
while (true){
spi_write2(0x01);
delay_ms(1);
}
} |
May come in usefull if anyone has the same problem for testing purposes, don't know if there is a problem with the chip, typically was the last one I had (was brand new)
Anyway guys, taken enough of your time on this, thanks for the suggestions etc
Chris |
|
 |
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Fri Feb 05, 2010 7:16 am |
|
|
| May be it's a defective exemplar or a 24HJ128GP504 silicon issue. I don't have the chip and can't check it. |
|
 |
bkamen
Joined: 07 Jan 2004 Posts: 1619 Location: Central Illinois, USA
|
|
Posted: Fri Feb 05, 2010 7:28 am |
|
|
I had weird problems with 16bit SPI in the past using PCD.
I ended up writing my own routines that would check the SPITBF flag before writing to SPIREG and that worked in 8 and 16bit mode.
I think also you should check to make sure it's being set to 16bit mode via the MODE16 bit.
Don't be surprised if you have to write to SPIREG directly like I did.
I just recently did another complex SPI project using 16bit framed mode and was fiddling bits directly instead of using SPI_ReAD/Write or XFER.
Here's my example for 8bit on a PIC33F
| Code: | #locate SPI2_STAT = 0x226
#locate SPI2_CON = 0x228
#locate SPI2_BUFF = 0x22A
#bit SPI2_TBF = SPI2_STAT.1
#bit SPI2_16B = SPI2_CON.10
void mb90050_send_cmd ( unsigned int cmd ) {
unsigned int8 hi=0, lo=0;
hi = make8( cmd, 1 );
lo = make8( cmd, 0 );
if ( !mb90050_select() ) { // non-Zero = timeout as IC is busy
#ifdef use_CCS_SPI
spi_xfer(VIDEO, hi);
spi_xfer(VIDEO, lo);
#else
SPI2_BUFF = hi;
while ( SPI2_TBF );
SPI2_BUFF = lo;
#endif
delay_us(SPI_DELAY);
mb90050_deselect();
}
} |
Because I was sending 16bit commands and some 8bit data, I just kept the SPI in 8bit mode as switching would mean extra work... and really didn't matter for my purpose (didn't need speed). _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
 |
logical
Joined: 21 Dec 2009 Posts: 57 Location: SouthPort, UK
|
|
Posted: Fri Feb 05, 2010 12:25 pm |
|
|
| FvM wrote: | | May be it's a defective exemplar or a 24HJ128GP504 silicon issue. I don't have the chip and can't check it. |
Wouldn't expect you to, have never met as many helpful people as on this forum
@Bkamen, will be sure to give that a go, I do recall seeing a post from you recently with the SPI problems.
I will (just got some more pic 24's in) replace the processor and post my findings on here, hopefully any info I can provide with reference to this may help others if they have the same problem, obviously not much use if it turns out to be a faulty chip though  |
|
 |
|
|
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
|