AnsweredAssumed Answered

ADuC7060 Master code for SPI interfacing

Question asked by poornendu on Mar 22, 2013
Latest reply on Mar 25, 2013 by MMA

I intend to interface multiple devices on SPI bus using ADuC7060. Can you please help me in the code for the same.

I've done following:

 

//Enable Interrupts

    IRQEN |= BIT10 + BIT11;                     // Enable UART and ADC interrupts

    IRQCONE = BIT1;                                      // Rising edge of XIRQ0

    IRQEN |=  BIT12;                                      // Enable SPI Interrupt

    IRQEN |=  BIT13;                                      // Enable External IRQ0

 

 

//Setup SPI interface

    GP0CON0 = BIT0 + BIT4 + BIT8 + BIT12; //Select SPI/I2C alternative function for P0[0...3]

    GP0KEY1 = 0x7; //Write to GP0KEY1

    GP0CON1 &=~ BIT1; //Select SPI functionality for P0.0 to P0.3

    GP0KEY2 = 0x13; //Write to GP0KEY2

 

SPICON = BIT0 + BIT1 + BIT6         //Enable SPI, Master, MSB First, transfer by write to SPITX,

              + BIT11 + BIT14 + BIT15;  //Continuous transfer, Interuppt after transfer of 4 bytes

 

I plan to write to SPI using

SPITX = BIT0 + BIT3;

 

When I run the program SPI interrupt is continuously occuring.

 

What I'm doing wrong?

 

What should I do to write 4 bytes to SPI and then disable chip select (SS bar)?

Outcomes