16F1716 ile spi haberleşmesi yapmaya çalişiyorum fakat datasheet baktım ama anlayamadım
spi bacaklarında RC4 >> SPI Data input gozukuyor;
SPI data output ve SPI clock output hangi port onu anlayamadım OUT(2)diye bir kısım var ordan bahsediyor birşeyler
Olay şu, bir tek bacak bu iş için kullanılmıyor, sen istediğin bir bacağı bu iş atayabiliyorsun.
MPLAB kullanabiliyorsan, MPLABX üzerinde "code configurator" diye bir eklenti (menü) var orada, bu seçme olayının sadece clk ile sınırlı olmadığını görebilirsin...Portb ve Portc üzerindeki bacaklardan birine atayabilirsin.
Ben CCS ile programlamaya çalişiyorum ccs de nasıl olacak ccs hakkında bilgisi olan varmi bu konuda
Konu: CcsC Peripheral Pin Select
Datasheet > APFCON registerı,
veya
CCSC
//Alternatif pin seçimi
#pin_select hangi modül (uart, spi vs.) = hangi pine (hangi pinler olabiliyorsa) //
örneğin:
//Pin selects for reprogrammable pins
#pin_select U1TX = PIN_B6 //output serial
#pin_select U1RX = PIN_B7
proteus 8.3 sp3 de devre kurdum 16f1708 entegresi ile dediğiniz gibi yapmaya çaliştim ne etiysem olmadi başaramadım haberleşmiyor
ekte dosyları verdim
ALICI
#include <16F1708.h> //PIC 8bits
#use delay(clock=4000000)
#FUSES NOWDT
#FUSES PUT //Power Up Timer
#FUSES PROTECT //Code not protected from reading
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT
#FUSES NOMCLR //Program memory not write protected
#FUSES INTRC_IO
#define button1 PIN_A0
#define button2 PIN_A1
#define LED3 PIN_C5
#define LED1 PIN_C6
#define LED2 PIN_C7
#pin_select SCK1 = PIN_B4
#pin_select SDI1 = PIN_B6
#pin_select SDO1 = PIN_B5
#use spi(FORCE_HW, stream=SPI_STREAM,BITS=8)
void kesme_led();
int8 gelen;
#int_ssp // SPI iletişiminde yazma veya okuma yapıldığında meydana gelen kesme
void SPI_kesmesi()
{
disable_interrupts(int_ssp);
kesme_led();
enable_interrupts(int_ssp);
}
void kesme_led()
{
delay_ms(100);
output_toggle(LED3); // Gecikme veriliyor
}
void main(){
set_tris_a(0B00000011);
set_tris_b(0B01010000);
set_tris_c(0B00000000);
output_a(0B00000000);
output_b(0B00000000);
output_c(0B00000000);
setup_oscillator(OSC_4MHZ);
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_timer_0(T0_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_ccp1(CCP_OFF);
setup_ccp2(CCP_OFF);
setup_vref(VREF_COMP_DAC_2v048);
setup_dac(DAC_VSS_FVR);
setup_spi(SPI_SS_DISABLED);
setup_spi(SPI_SLAVE|SPI_L_TO_H|SPI_CLK_DIV_4|SPI_STREAM);
enable_interrupts(global);
enable_interrupts(int_ssp);
while(true)
{
if(spi_data_is_in()==1)
{
gelen=spi_read();
if( gelen==0X80)
{output_high(LED1);}
if( gelen==0XA)
{ output_high(LED2);}
}
}
}
verici
#include <16F1708.h> //PIC 8bits
#use delay(clock=4000000)
#FUSES NOWDT
#FUSES PUT //Power Up Timer
#FUSES PROTECT //Code not protected from reading
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT
#FUSES NOMCLR //Program memory not write protected
#FUSES INTRC_IO
#pin_select SCK1OUT = PIN_B4
#pin_select SDI1 = PIN_B6
#pin_select SDO1 = PIN_B5
#use spi(FORCE_HW,stream=SPI_STREAM,BITS=8)
#define button1 PIN_A1
#define button2 PIN_A0
#define LED1 PIN_C6
#define LED2 PIN_C7
#define LED3 PIN_C5
int8 gelen;
void main(){
set_tris_a(0B00000011);
set_tris_b(0B01000000);
set_tris_c(0B00000000);
output_a(0B00000000);
output_b(0B00000000);
output_c(0B00000000);
setup_oscillator(OSC_4MHZ);
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_timer_0(T0_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_ccp1(CCP_OFF);
setup_ccp2(CCP_OFF);
setup_vref(VREF_COMP_DAC_2v048);
setup_dac(DAC_VSS_FVR);
setup_spi(SPI_SS_DISABLED);
setup_spi(SPI_MASTER|SPI_L_TO_H|SPI_CLK_DIV_4|SPI_XMIT_L_TO_H|SPI_STREAM);
//! enable_interrupts(global);
//! enable_interrupts(int_ssp);
//!
while(true)
{
if( input(button1) )
{
output_high(LED1);
spi_write(0X80);
delay_ms(10);
}
else
{
output_low(LED1);
}
if( input(button2) )
{
output_high(LED2);
spi_write(0XA);
delay_ms(10);
}
else
{
output_low(LED2);
}
if( gelen==10 )
{
output_toggle(LED3);
}
}
}
proteus dosyası (proteus 8.3)
spi - Kopya.zip - 204 KB (http://dosya.co/gia8hhiqvynw/spi_-_Kopya.zip.html)