This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ST10F269 with MCP2515 via SSC interface

Hi,
I am interfacing ST10F269 with MCP2515 via SSC module. Please see the routines as below, i am still not able to read valid values from register CANCTRL at address 0x0F. i wish to upload the waveforms but dont see an option here.

initialisation routines :
NOP
        BSET DP3.6                      ;Chip Select
        BSET P3.6
        BCLR    DP3_8           ;MRST pin
        BCLR    P3_8
        BSET    DP3_9           ;MTSR pin
        BSET    P3_9
        BSET    DP3_13          ;SCLK
        BSET    P3_13
        MOV SSCBR, #0x00C7 ;100K baudrate
        BCLR SSCEN
        MOV SSCCON, #0x4077
        BSET SSCEN

ENIT

CODE :
#define MCP_SELECT() (P3_6 = 0)
#define MCP_DESELECT() (P3_6 = 1)
unsigned int spi_readwrite(BYTE data)
{
int test = 0;
SSCTB = data;    //Byte in Sende buffer
while(SSCBSY == 0);//wait till SSCBUSY becomes 1 i.e. when transmission starts SSCBSY becomes 1

while (!SSCRIR); //wait till byte is sent(SSCRIR = 1)
SSCRIR = 0;              //clear the flag
return SSCRB ;

}

unsigned int spi_read(void)
{
        return (spi_readwrite(SPIDONTCARE));
        //return SSCRB ;
}

CALLING FUNCTIONS :

MCP_SELECT();
spi_readwrite(0x03);    //MCP_READ = 0x03
spi_readwrite(0x0F);
status_register = spi_read();
MCP_DESELECT();

Please let me know if i am doing something wrong. Its very urgent.

Rgds
Sany

Parents Reply Children