This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE?: RE: RE: RE: [ECOS] Does AT91 SPI dr iver support external SPI devices?


Mornin',

I have tested the code you gave me to test the GPIO functiuns and it works well! So the problem doesn't become from the GPIO functions. They works under AT91M55800A.

To understand what the multiplexor does, I have studied its datasheet. If I would like to activate the NSPICS5, I have to put the next values:NSPCS0=1, NSPCS1=0, NSPCS2=1, NSPCS0=3. I did it with the next code. By this way, I think that the dev_num value is ignored. Am I right? :

static void
spi_at91_set_npcs(cyg_spi_at91_bus_t *spi_bus,int val)
{
   HAL_ARM_AT91_GPIO_PUT(AT91_SPI_NPCS0, 1);
   HAL_ARM_AT91_GPIO_PUT(AT91_SPI_NPCS1, 0);
   HAL_ARM_AT91_GPIO_PUT(AT91_SPI_NPCS2, 1);
   HAL_ARM_AT91_GPIO_PUT(AT91_SPI_NPCS3, 0);
}

As I was not sure of the NPCS3 value, I tried to change it and no changes appeared. I made many measures before/after the multioplexor and on the final board's pins. I checked the connections between pins of board and multiplexor, they are OK. No changes appears on the final board's pins.

Are you sure that the switches inside the processor are closed (see attached schema)? I have never seen this operation... If I want to close it anyway, have I got to use the HAL_WRITE_UINT32 function with the address and the value of the corresponding register?

Thank you very much for help! Regards,

Stéphane


 

________________________________

> Yes, the processor is a AT91M55800A. Effectively, it has only one SPI device.
>
> First, I printed the values of "val" in the set_npcs
> function. Effectively, they change when I change the dev_num
> value. As I understand the function and the values printed, it is
> not writed to work with a multiplexor.

Yes it is. Look at spi_at91_start_transfer() where it calls
spi_at91_set_npcs().

> static void
> spi_at91_set_npcs(cyg_spi_at91_bus_t *spi_bus,int val)
> {
>    /*cyg_uint32 ctr;
>    for(ctr=0;ctr<4;ctr++)
>    {
>       printf("### val1=%i, val2=%i ###\n",val, (val & (1<<ctr)));
>       if(spi_bus->cs_en[ctr])
>       {
>         HAL_ARM_AT91_GPIO_PUT(spi_bus->cs_gpio[ctr], (val & (1<<ctr)));
>       }
>    }*/
>   
>    HAL_ARM_AT91_GPIO_PUT(spi_bus->cs_gpio[0], 0);
>    HAL_ARM_AT91_GPIO_PUT(spi_bus->cs_gpio[1], 1);
>    HAL_ARM_AT91_GPIO_PUT(spi_bus->cs_gpio[2], 0);
>    HAL_ARM_AT91_GPIO_PUT(spi_bus->cs_gpio[3], 1);
> }
>

> I have tried many values for the different bits because I don't know
> which is the MSB and the LSB. No changes appeared. I never had the
> chip select CS5-8 activated.

And what happens to the actual chip pins, not the demultiplexor pins.
Does the chip pins change?

It could be something like the GPIO functions are not working for the
AT91M55800A.

Which pin is your LED on?

Try something like:
HAL_ARM_AT91_GPIO_CFG_DIRECTION(AT91_PIN_LED, AT91_PIN_OUT);
for(;;) {
        HAL_ARM_AT91_GPIO_PUT(AT91_PIN_LED,0);
        cyg_thread_delay(100);
        HAL_ARM_AT91_GPIO_PUT(AT91_PIN_LED,1);
        cyg_thread_delay(100);
}


Attachment: SPI Block Diagram.JPG
Description: SPI Block Diagram.JPG

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]