SPI problem when using dspic30f4011 to communicate with MCP42050 sensor

Status
Not open for further replies.

lopex

Junior Member level 1
Joined
Jan 16, 2008
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,399
hi,


I use a dspic30f4011 to communicate with a digital resistor, MCP42050, but the resitor not change the value.
Someone can help me?

code:

#include <spi.h>
// ...
void conf_spi(void){
unsigned int SPICONValue;
unsigned int SPISTATValue;
unsigned int data;
int i;
//config
SPICONValue = FRAME_ENABLE_OFF &
FRAME_SYNC_OUTPUT &
ENABLE_SDO_PIN &
SPI_MODE16_ON &
SPI_SMP_ON &
SPI_CKE_OFF &
//SLAVE_SELECT_ENABLE_OFF&
CLK_POL_ACTIVE_HIGH &
MASTER_ENABLE_ON &
SEC_PRESCAL_7_1 &
PRI_PRESCAL_64_1;

SPISTATValue = SPI_ENABLE &
SPI_IDLE_CON &
SPI_RX_OVFLOW_CLR;


OpenSPI1(SPICONValue,SPISTATValue );

i=0;
LATDbits.LATD0=1; //put SC=1
data=0b1101001101001000; //11010011 01001000

LATDbits.LATD0=0; //put SC=0
putcSPI1(data);
while(SPI1STATbits.SPITBF==1);

//--------delay----------
for(i=0;i<350;i++){
i++;
i--;
}

LATDbits.LATD0=1; //put SC=1
CloseSPI1();

}


Thanks

lopex
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…