Hello, i'm new with the AD7705 and when i lanch my program, i only see the when CS goes low...
i'm using a pic16f18344 (master) with a ad7705 (slave) in SPI communication

And here is my code :
#define _XTAL_FREQ 16000000
// CONFIG1
#pragma config FEXTOSC = OFF // FEXTOSC External Oscillator mode Selection bits (Oscillator not enabled)
#pragma config RSTOSC = HFINT1 // Power-up default value for COSC bits (HFINTOSC (1MHz))
#pragma config CLKOUTEN = OFF // Clock Out Enable bit (CLKOUT function is disabled; I/O or oscillator function on OSC2)
#pragma config CSWEN = ON // Clock Switch Enable bit (Writing to NOSC and NDIV is allowed)
#pragma config FCMEN = OFF // Fail-Safe Clock Monitor Enable (Fail-Safe Clock Monitor is disabled)
// CONFIG2
#pragma config MCLRE = ON // Master Clear Enable bit (MCLR/VPP pin function is MCLR; Weak pull-up enabled)
#pragma config PWRTE = ON // Power-up Timer Enable bit (PWRT enabled)
#pragma config WDTE = OFF // Watchdog Timer Enable bits (WDT disabled; SWDTEN is ignored)
#pragma config LPBOREN = OFF // Low-power BOR enable bit (ULPBOR disabled)
#pragma config BOREN = ON // Brown-out Reset Enable bits (Brown-out Reset enabled, SBOREN bit ignored)
#pragma config BORV = HIGH // Brown-out Reset Voltage selection bit (Brown-out voltage (Vbor) set to 2.7V)
#pragma config PPS1WAY = OFF // PPSLOCK bit One-Way Set Enable bit (The PPSLOCK bit can be set and cleared repeatedly (subject to the unlock sequence))
#pragma config STVREN = OFF // Stack Overflow/Underflow Reset Enable bit (Stack Overflow or Underflow will not cause a Reset)
#pragma config DEBUG = ON // Debugger enable bit (Background debugger enabled)
// CONFIG3
#pragma config WRT = OFF // User NVM self-write protection bits (Write protection off)
#pragma config LVP = OFF // Low Voltage Programming Enable bit (High Voltage on MCLR/VPP must be used for programming.)
// CONFIG4
#pragma config CP = OFF // User NVM Program Memory Code Protection bit (User NVM code protection disabled)
#pragma config CPD = OFF // Data NVM Memory Code Protection bit (Data NVM code protection disabled)
#include <xc.h>
#include <pic16f18344.h>
#include <stdint.h>
/////////// CAN ////////////
#include <math.h>
#define SCK RC0 //Serial Clock
#define SDI RC1 //Serial Data In
#define SD0 RC2 //Serial Data Out
#define SS RC3 //Slave Select: Not used in this application
#define DRDY RB6
#define RESET RB5
#define NUM_SAMPLES 1000 /* change the number of data samples */
#define MAX_REG_LENGTH 2 /* this says that the max length of a register is 2 bytes */
//modes de configs
#define ADC_NORMAL 0x00
#define ADC_SELF 0x40
#define ADC_ZERO_SCALE 0x80
#define ADC_FULL_SCALE 0xc0
//Réglages de gain
#define ADC_GAIN_1 0x00
#define ADC_GAIN_2 0x08
#define ADC_GAIN_4 0x10
#define ADC_GAIN_8 0x18
#define ADC_GAIN_16 0x20
#define ADC_GAIN_32 0x28
#define ADC_GAIN_64 0x30
#define ADC_GAIN_128 0x38
//Unipolaire ou Bipolaire
#define ADC_BIPOLAR 0x04
#define ADC_UNIPOLAR 0x00
//Fréquence d'envoi
#define ADC_50 0x04
#define ADC_60 0x05
#define ADC_250 0x06
#define ADC_500 0x07
uint8_t prems;
uint8_t deus;
void Init_Horloge(void){
//// HORLOGE ////
OSCCON1 = 96;//96+?
OSCEN=64;
OSCFRQ = 6;
}
void CAN_Init(void)
{
SSPBUF = 0; // init buffeur spi
SS = 1; // Slave select init
//// PORTS SPI SENS ////
TRISC3 = 0; // Slave select en sortie
TRISC0 = 0; // SCK en sortie
TRISC1 = 1; // SDI en entrée
TRISC2 = 0; // SDO en sortie
TRISB6 = 1; // DRDY CAN en entrée
TRISB5 = 0; // RESET Sortie
//// SPI PPS ////
RC0PPS= 24; //Affectation sck
RC2PPS = 25; //Affectation sdo
//// SPI CONFIG ////
SSP1STAT = 128; // mesure millieu safe
SSP1CON1 = 34; //SPI enable + Mode maitre
SSP1CON3 = 16; //Autorisation overwrite
ADCON0 = 0 ; // Désactivation du CAN
ANSELA = 0;
ANSELC = 0;
ANSELB = 128;
}
//////////////////////// ECRITURE CAN /////////////////////
void write_adc_byte(uint8_t data)
{
SS = 0; // Activation Slave select
//RB7 = 0 ;
SSP1BUF = data;//envoi dans buffer
while(!SSP1IF){}
SSP1IF = 0; // doit être remis à 0 manuellement
//RB7 = 1;
SS = 1;// désactivation Slave select
}
//////////////////////// LECTURE CAN /////////////////////
uint8_t read_adc_word()
{
uint8_t data2_msb;
uint8_t data2_lsb;
while(DRDY ==1){}
SS = 0;
SSP1BUF = 0;
while(!SSP1IF){}
SSP1IF = 0;
data2_lsb= SSP1BUF; //envoi dans buffer
SSP1BUF = 0;
while(!SSP1IF){}
SSP1IF = 0;
data2_msb= SSP1BUF; //envoi dans buffer
SS = 1;
//while ( DRDY == 0 ){};
return data2_lsb;
}
//Configurations
void setup_adc_device(int calmode, int gainsetting, int operation, int rate)
{
write_adc_byte( 32 );//Registre de communications réglé pour écrire dans le registre d'horloge
write_adc_byte( 12 );//Registre d'horloge
write_adc_byte( 16 );//Registre de communications réglé pour écrire dans le registre de setup
write_adc_byte( 64 );//Registre de setup
}
//initailaization routine
void adc_init()
{
RESET = 0;//Etat bas reset
RESET = 1; //Etat haut reset
//setup_adc_device(ADC_SELF,ADC_GAIN_1,ADC_BIPOLAR,ADC_50); // Lancement config
}
void adc_disable()
{
write_adc_byte( 0x20 );
write_adc_byte( 0x10 );
}
//Convertir la valeur lue en volts
float convert_to_volts(long data){
return ((float)data*2.5/0xffff);
}
void main(void) {
Init_Horloge();
CAN_Init();
RB7 = 0;
adc_init();
write_adc_byte( 32 );//Registre de communications réglé pour écrire dans le registre d'horloge
write_adc_byte( 7 );//Registre d'horloge
write_adc_byte( 16 );//Registre de communications réglé pour écrire dans le registre de setup
write_adc_byte( 64 );//Registre de setup (+56 pour gain max)
while(DRDY ==1){}
while(1){
write_adc_byte(56);
//__delay_ms(10);
prems= read_adc_word();
UART_Write(32);
}
return;
}
My sending spi is good but i don' see any data into my dataout pin
PLS help

















