Tony Kübek, Flintab AB says:
According to the data for the F876, regarding the SPI module I paraphrase ( DS30292-A page 66 ):" - SDI is automatically controlled by the SPI module "
Then after the table it states:"Any serial port function that is not desired may be overridden by programming the ....TRIS register to the opposite value"
I just spent 3 hour tracking down the obvious bug of setting the SDI as an output ( as I only read the first paragraph ). Is it only me ( I'm not native English ) but aren't these statements actually wrong ? ( they opposite each other ).
Anyway, if anyone cares here the lesson: ALWAYS ( exept UART TX/RX ;-) ) set the pin they way you will use it, i.e. outputs ( ex. SDO ) should have TRIS bit cleared, inputs ( ex. SDI ) should have TRIS bit set.
Galen O'Grady askes
I am using a 16C63 as an SPI slave (with SS* enabled). When doing multi-byte transfers, does the SS* pin need to be cycled (by the master) after each byte, or can it remain low for the entire transfer?
David Kott [dkott at TESTPROD.COM] answers:
No. You do not need to cycle it between each byte transfer. To wit, to test this notion, setup your SPI in slave mode with SS control enabled, and ground the SS line. The SPI will function identically, provided you are transferring 8 bits per word (as you implied when you described the data as a "byte")
Recently, I was having an issue with my SPI Slave code. I had SS control enabled. However, it seems that the device sourcing the SS signal was not conforming to the timing requirements for the PIC. Merely grounding the SS line allowed the SPI subsystem to function properly. Subsequently, I configured my SPI to not use SS control.
The PICmicro Mid-Range MCU Family manual says this:"When the SPI is in Slave Mode with SS pin control enabled, (SSPCON<3:0> = 0100) the SPI module will reset if the SS pin is set to VDD. If the SPI is used in Slave Mode with the CKE bit is set, then the SS pin control must be enabled. When the SPI module resets, the bit counter is forced to 0. This can be done by either by forcing the SS pin to a high level or clearing the SSPEN bit..." (c) Microchip Technology Inc.
Sample 16F876 code with SPI master setup as well as RS232, etc... by Tony Kübek
SPI interface to AD7730 by Tony Kübek
SPI Slave for PIC 16c73 by Josef Hanzal, M. S.
SPI to MAX7221 LED Driver by Marcel Birthelmer
"Serial PIC'n : PIC Microcontroller Serial Communications" by David Benson
General SPI (not PIC specific)
Dear Sir/Madam, I am developing SD memory card in SPI mode with PIC16F877A. My definition is inserted at the end of this email. But this setup does not work. When I run my code in PIC simulator, I came into conclusion that I have no output clock on PIN_C3. Would you please help me if you can! Regards/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #define SD_SELECT PIN_A5 #define SD_CLK PIN_C3 #define SD_DO PIN_C5 #define SD_DI PIN_C4 #include <16F877A.h> #fuses HS,NOWDT,NOPROTECT,NOLVP #use delay(clock=20000000) #use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) // Jumpers: 8 to 11, 7 to 12 SETUP_SPI(SPI_MASTER | SPI_H_TO_L | SPI_CLK_DIV_4 | SPI_SS_DISABLED); *0x94 |= 0x40; // set CKE = 1 - clock idle low *0x14 &= 0xEF; // set CKP = 0 - data valid on rising edge //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
What is the maximum rate I can clock data into one of the fastest PICs (18x series, I assume) SPI port in slave mode? I need to be able to read in a serial stream at 11 Mhz ... The 40MHZ osc parts I've looked up seem to handle 10 Mhz. Think these could handle 11Mhz input ... perhaps if I clocked it faster, say 44Mhz?
Alternatively, know of other uC which can read in synchronized serial data at 11Mhz clock rate?
Any ideas are appreciated! Thanks
http://www.piclist.com/techref/piclist/projects.htm I am using Pic16f876 to program. I used spi model to drive a shift register 74LS164 that connected 8 leds. how the program can let leds display battery voltage?
Have you ever worked with ADE7756? I can't read the Waveform register,how you can read this register and how do you know if it is the right value? thanks in advanced!
INIT_PORTS does set the OPTION register for SPI operation
The OPTION register has nothing to do with SPI. It controls TMR0 and port_b pullups.
v joshi Says: " hi friends,
Can anybody know what is the data rate of an SPI with pic operating Master Clock =4MHz
shridhar " Shaun D Johsnon of ElectroLogic Inc. replies: I'm working with a PIC 18FXX20 series chip(and am pretty sure its the same with other PIC chips), and you set the SPI master clock rate in the SSPCON register bits 3:0 (SSPM2:SSPM0), it will be the frequency of your oscillator dived by either 4,16, or 64 Shaun+
|file: /Techref/microchip/spi.htm, 10KB, , updated: 2008/12/30 19:20, local time: 2023/3/28 07:46,
|©2023 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?|
<A HREF="http://www.sxlist.com/techref/microchip/spi.htm"> PIC SPI</A>
|Did you find what you needed?|
Welcome to sxlist.com!
& kind contributors
just like you!
Please don't rip/copy
Copies of the site on CD
are available at minimal cost.
Welcome to www.sxlist.com!