> There is also the issue of the SPI clock -- the lower bits of SSPCON.
> The user may want to tweak these. for different speeds, or even a
> different clock source.

yes, the speed is chosen by the lower 4 bits of SSPCON register, the
user can choose the speed. These lower bits are defined as
SSPCON_SSPM, it is bit*4 in 16f877.jal

The only valid values for SPI Master for both 16F and 18F 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

so we can do the following:

16f pics:
ALIAS spi_master_speed = SSPCON_SSPM

18f pics:
ALIAS spi_master_speed = SSP1CON_SSPM

so in the example file, the user can have "spi_master_speed = 1" for
FOSC/16

these registers can go in the init routine:
SSPCON_CKP   = 1  -- idle state for clock is high level
SSPSTAT_CKE  = 0  -- clock edge select, data transmitted on falling
edge of sck
SSPCON_SSPEN = 1  -- enables serial port and configures sck, sdo, sdi
and ss as source of the serial port pins
SSPSTAT_SMP  = 0  -- sample bit, input data sampled at middle of data
output time

> So, how many different picmicro chips can you test with your SD card
> or possibly other SPI slave devices?
>
> I've got some 18F parts I can try out, when I have some spare time.
> Not sure when that will be though.  And I'm only testing mode 0,0,
> although I've read that SD cards also work in mode 1,1.

I only have 16F877, 16F877A and 18F452. You can build my SD circuit if
you wish, it is quite simple.

SD cards use mode 1,1 only, CKP = 1, CKE = 0

> ps:  Did you notice the leading underscore in my _init() routine?  I
> never intended for anyone to use it  (other than me.  lazy I guess)

Well, it looks like we may have 4 of your init routines for the
different modes!

when this lib is done, my sd_card lib will be done as well.

Matt.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jallib?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to