View previous topic :: View next topic |
Author |
Message |
picj1984
Joined: 01 Mar 2010 Posts: 73
|
[SOLVED] Trouble getting SPI to work on PIC16F1509 |
Posted: Wed Jul 11, 2018 4:30 pm |
|
|
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
|
|
Posted: Wed Jul 11, 2018 4:47 pm |
|
|
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
|
|
Posted: Wed Jul 11, 2018 11:20 pm |
|
|
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
|
solved! |
Posted: Thu Jul 12, 2018 11:12 am |
|
|
y'all are a bunch of geniuses. |
|
|
|