JerryR
Joined: 07 Feb 2008 Posts: 168
|
No SPI clocks |
Posted: Tue Jul 15, 2025 9:58 am |
|
|
Hi Group, thanks for your help on this-
I am using PCWH v5.093 to compile code for a PIC18F86J60. I am posting a small snippet of code below. I am using the hardware SPI1 to talk to two external SPI devices
The problem is that using either of the use_spi setups, results in no clocks being issue when attempting to write to a SPI device. The Data Out looks reasonable, however, but no clock pulses.
If I comment out both spi_setup statements, I can generate clock pulses on the clock pin (PIN_C3), so there's nothing in the hardware blocking the clock pin.
This is probably something very simple, but I just can't see it. Here's the code:
Code: |
#include <18F86J60.h>
#device ADC=10
#FUSES NOWDT //No Watch Dog Timer
#use delay(crystal=25000000)
#use spi (MASTER, DI=PIN_C4, DO= PIN_C5, CLK= PIN_C3, BITS=8, MODE=0)
//#use spi (MASTER, SPI1, BITS=8, MODE=0)
void main()
{
setup_adc_ports(AN0_TO_AN1, VSS_VDD);
setup_adc(ADC_CLOCK_INTERNAL | ADC_TAD_MUL_0);
output_high(PIN_A3);
output_low(PIN_A3);
delay_us(10);
spi_write (0x50);
spi_write(0x00);
spi_write(0xFF);
delay_us(10);
output_high(PIN_A3);
while(TRUE)
{
}
}
|
|
|