CCS compiler

Published on January 2017 | Categories: Documents | Downloads: 53 | Comments: 0 | Views: 329
of 1
Download PDF   Embed   Report



#include <16F876A.h> #device *=16 #device adc=8 #FUSES NOWDT #FUSES HS r PCD) #FUSES NOPUT #FUSES NOBROWNOUT #FUSES NOLVP used for I/O #FUSES NOCPD #FUSES NOWRT #FUSES NODEBUG #FUSES NOPROTECT //No Watch Dog Timer //High speed Osc (> 4mhz for PCM/PCH) (>10mhz fo //No Power Up Timer //No brownout reset //No low voltage prgming, B3(PIC16) or B5(PIC18) //No EE protection //Program memory not write protected //No Debug mode for ICD //Code not protected from reading

#use delay(clock=20000000) #use rs232(baud=9600, parity=N, xmit=PIN_C6, rcv=PIN_C7, bits=8) #define #define #define #define SPI_MODE_0 SPI_MODE_1 SPI_MODE_2 SPI_MODE_3 (SPI_L_TO_H | SPI_XMIT_L_TO_H) (SPI_L_TO_H) (SPI_H_TO_L) (SPI_H_TO_L | SPI_XMIT_L_TO_H)

void main() { setup_spi(SPI_SLAVE | SPI_MODE_1); //set up SPI hardware as a slave in mode 1 int val; while(true) { val = spi_read(0); //spi_read must be passed an argument. The argument va lue is sent //back to the master whenever the master sends us a me ssage again. //This allows two-way communication, but here the mast er ignores //whatever the slave sends back, so just send a 0. //display the value read: printf("Pot at: %u ", val); } }

Sponsor Documents

Or use your account on


Forgot your password?

Or register your new account on


Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in