Ram Prasadh
Member level 2
Hello ,
I am presently into a project which uses a PIC16F72 with a MAXQ3180 which is a power measurement IC. If someone knows about PIC programming for Spi , Please have a look at the code written below and please help me. There is a problem in that code . Am not able to find it. Might be I would have not checked some registers. here s my code>>>
#include<htc.h>
#define SS PORTAbits.RA5//slave select bit is assigned to porta 5th pin
void spi();
void delay();
typedef unsigned int word;
word __at 0x2007 CONFIG = _HS_OSC & _WDT_OFF & _PWRTE_OFF & _CP_OFF & _BODEN_ON;
void main(void)
{
ADCON1=0x06;//configured as digital and not analog
TRISA=0;
TRISC=0;
TRISCbits.TRISC4=1;// SDI is made as an input,SCK,SDO are output
spi();
}
void spi()
{
while(1)
{
/*_ _ _ _ _ _ _ _ _ SSP CONFIGIRATION_ _ _ _ _ _ _ _ _ */
SSPCON=0b00110001;
SSPSTAT=0b10000000;
SS=0x00;
WREG=0x23;
SSPBUF=WREG;
while(BF=0x00);
PORTB=SSPBUF;
SS=1;
}
}
........Waiting for a Reply... Help me Please
I am presently into a project which uses a PIC16F72 with a MAXQ3180 which is a power measurement IC. If someone knows about PIC programming for Spi , Please have a look at the code written below and please help me. There is a problem in that code . Am not able to find it. Might be I would have not checked some registers. here s my code>>>
#include<htc.h>
#define SS PORTAbits.RA5//slave select bit is assigned to porta 5th pin
void spi();
void delay();
typedef unsigned int word;
word __at 0x2007 CONFIG = _HS_OSC & _WDT_OFF & _PWRTE_OFF & _CP_OFF & _BODEN_ON;
void main(void)
{
ADCON1=0x06;//configured as digital and not analog
TRISA=0;
TRISC=0;
TRISCbits.TRISC4=1;// SDI is made as an input,SCK,SDO are output
spi();
}
void spi()
{
while(1)
{
/*_ _ _ _ _ _ _ _ _ SSP CONFIGIRATION_ _ _ _ _ _ _ _ _ */
SSPCON=0b00110001;
SSPSTAT=0b10000000;
SS=0x00;
WREG=0x23;
SSPBUF=WREG;
while(BF=0x00);
PORTB=SSPBUF;
SS=1;
}
}
........Waiting for a Reply... Help me Please