vsmguy
Joined: 13 Jan 2007 Posts: 91
|
#use spi, selecting baud mode and slave select logic |
Posted: Fri Apr 19, 2013 1:28 pm |
|
|
A SPI slave I am using (a FRAM device) requires me to hold the SS line low for multiple bytes in the same transaction (the first byte in a transaction is the command byte followed by context dependent bytes)
I would like to use a SPI clock frequency of 1MHz. The master is a PIC16F877A @20Mhz HS. The hardware SPI peripheral is unavailable.
My current soft SPI code looks like this:
Code: | #define FRAMSD_PIN_SELECT PIN_D0
#use spi(STREAM=SPI2, MASTER, bits=8, mode=3, DI=PIN_D3, DO=PIN_D2, CLK=PIN_D1)
|
1. What value of 'BAUD' should I select so that the SPI clock frequency is 1MHz? 1000000?
2. Also, is there a way to have the following hold the SS line low for multiple bytes in the same transaction or do I have to handle the ENABLE pin myself manually?
Code: | #use spi(STREAM=SPI2, MASTER, bits=8, mode=3, ENABLE=FRAMSD_PIN_SELECT, ENABLE_ACTIVE=0, DI=PIN_D3, DO=PIN_D2, CLK=PIN_D1, BAUD=<1MHz>) |
|
|