On Tuesday, 22 August 2017 00:13:25 UTC+1, Matthew Schinkel wrote:
>
> Hi Alun,
>
> Try adding this just before your sd_card include: const 
> SD_DELAY_AFTER_WRITE = TRUE
>
> It sounds better to fix spi_master_sw_set_speed then to create a new 
> variable.
>
> Matt.
>
 
Hi Matt,

Sorry for the delay replying. I *thought* I'd set this post to notify me of 
updates, but that doesn't appear to have worked.

Thanks for the suggestion about SD_DELAY_AFTER_WRITE. It won't fix my 
problem though - the problem is that the software SPI is happening faster 
than the card can cope with it. Even reads fail when I don't have a delay 
in the software SPI bit shift routine.

While making spi_master_sw_set_speed work sounds best, making it have the 
same semantics as spi_master_set_hw_speed would be a problem, I think. 
spi_master_set_speed just takes its argument and assigns it to 
SSPCON1_SSPM. The relevant values of this bit field are:

0000 = SPI master mode, clock = FOSC/4
0001 = SPI master mode, clock = FOSC/16
0010 = SPI master mode, clock = FOSC/64
0011 = SPI master mode, clock = TMR2 output/2 

I guess the first three would be easy enough to translate into values for 
_usec_delay(). The last one (TMR2/2) would be a lot more complicated.

What do people think?

Cheers,
Alun.

-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/jallib.
For more options, visit https://groups.google.com/d/optout.

Reply via email to