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

Interfacing an LPC2119 with a MAX3100

Been trying to get a MAX3100 (UART-SPI interconnect) to work as a slave to an SPI Master in the LPC2119. Can't seem to get the clock to run (no pulse at pin), though Master mode is enabled. I'm out of UART ports on the controller, and I need to interface with a GPS chip.

This is my first time working with SPI, so I'm a bit lost, and I'd appreciate any help :)

Some background:

I need to send 0xC00B to the MAX to initialize it to 4800 baud. To read any input data from the 3100 I need to send 0x0000. I'm not using any pull-ups yet, I know the GPS is working for sure.

My code snippets are as follows:

Initialization:

PINSEL0=0x00055505; // Using P0.10 GPIO as CS
IO0DIR=0x0040F48C; // P0.10 configured as output
//SPI speed set to PCLK/240
S0SPCCR=0xF0;
//SPI control register configuration
S0SPCR=0xA0;  //set the SPI as master & Enable it
VICVectCntl0=0x2A;
VICVectAddr0= (unsigned long) SPI_ISR;
VICIntEnable |= 0x400;

Running:

SPI_write();    // MAX Initialization
while (SPI_status != 0)
{
        //infinite
}
IOSET0 = 0x400;

while(1)
{
        if(SPI_status == 0))
        {
                //SPI_status = 2;
                SPI_read(); // Normal running
                while (SPI_status == 2)
                {
                        UART0PutChar(S0SPSR);
                }

                while (SPI_status == 3)
                {
                        UART0PutChar(0x42);
                }
        }

Functions:

void SPI_write(void)
{
        IOCLR0 = 0x400; //Pull Chipselect low
        S0SPDR = 0xC0;  //Send WRITE opcode
        SPI_status = 1; //set next state
}

void SPI_read(void)
{
        IOCLR0 = 0x400; //Pull Chipselect low
        S0SPDR = 0x00;  //Send  READ code
        SPI_status = 2; //set next state
}


void SPI_ISR (void) __irq
{

        if ((S0SPSR & 0x80) == 0x80)
        {
                switch(SPI_status)
                {
                case (1):
                        S0SPDR = 0x0B;
                        SPI_status = 0;
                        break;

                case (2):
                        SPI_dummy = S0SPDR;
                        S0SPDR = 0x00;
                        SPI_status = 3;
                        break;

                case (3):
                        SPI_buffer = S0SPDR;
                        IOSET0 = 0x400;
                        SPI_status = 0;
                        break;

                default:
                        break;
                }
        }
        else
        {
                SPI_dummy       = S0SPSR;
                SPI_status      = 0;
        }

        S0SPINT = 0x01;  //Signal end of interrupt
        VICVectAddr = 0x00000000;
}

Thanks again for taking your time to read through this. I'll reply with any questions you may have about my connections / coding. And I'm open to any criticism about my coding style too!

0