CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

[SOLVED] Trouble getting SPI to work on PIC16F1509

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
picj1984



Joined: 01 Mar 2010
Posts: 73

View user's profile Send private message

[SOLVED] Trouble getting SPI to work on PIC16F1509
PostPosted: Wed Jul 11, 2018 4:30 pm     Reply with quote

Hello,

I'm looking at the pins with a scope and I can't seem to get anything going for SPI. Been working on in all day and I figure I must be doing something incredibly stupid. I simplified as much as possible here and still nothing:

DETAILS:

PCM Compiler V4.140
PIC161509
Target Voltage is 5V
Osc Speed 16MHz internal
Code:


#include <16f1509.h>
#fuses HS, NOWDT, NOLVP, PROTECT
#device ADC=10
#use delay(clock=16000000, int)
#use spi(MASTER, IDLE=1, SAMPLE_RISE, SPI1, FORCE_HW, ENABLE=PIN_C6, STREAM=STREAM1)




void main ()
{

while(1)
{

spi_xfer(STREAM1,80,16);
delay_ms(1000);

}
}


Last edited by picj1984 on Thu Jul 12, 2018 11:10 am; edited 1 time in total
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jul 11, 2018 4:47 pm     Reply with quote

Without even looking at your program too closely, I can say the loop delay
is way too long. See this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=56768
He shortened his loop delay and then he could see the SPI pulses.
Ttelmah



Joined: 11 Mar 2010
Posts: 19546

View user's profile Send private message

PostPosted: Wed Jul 11, 2018 11:20 pm     Reply with quote

Also, 'be aware', that SPI, if specified without a baud rate, will run as fast as possible, so without reading the data sheet and checking, I'd guess yours will be running at 4MHz. A fast clock to see especially with just 16 pulses sent once per second (a lot less if you are looking at the data line)....
picj1984



Joined: 01 Mar 2010
Posts: 73

View user's profile Send private message

solved!
PostPosted: Thu Jul 12, 2018 11:12 am     Reply with quote

y'all are a bunch of geniuses.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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