public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] Does AT91 SPI driver support external SPI devices?
       [not found] <F7620004260C5D4DB836EDBF8CC6872D028943B5@neptune.intra.eiaj.ch>
@ 2007-02-28 14:05 ` Julien Stéphane
  2007-02-28 14:43   ` Andrew Lunn
  0 siblings, 1 reply; 12+ messages in thread
From: Julien Stéphane @ 2007-02-28 14:05 UTC (permalink / raw)
  To: ecos-discuss; +Cc: nicolas.brouard, Etique Philippe

[-- Attachment #1: Type: text/plain, Size: 1299 bytes --]

Hi,
 
I still have problems to make SPI work on my AT91 evaluation board. I hava nothing to the SPI output of my AT91EB55 board (sniffing with scope). I've studied the datasheet of my processor and have seen the block diagram attached to this mail. Apparently, there are switches default openned to activate SPI signals. I didn't found in code where these switches are closed, so I have tried to write directly to the memory with HAL_WRITE_UINT32 to close them but no chages appears. Furthermore, I've studied the at91 SPI driver code and I have readed this comment in the function spi_at91_transaction_begin() : 
 
    /* As we are using this driver only in master mode with NPCS0 
       configured as GPIO instead of a peripheral pin, it is neccessary 
       for the Mode Failure detection to be switched off as this will
       cause havoc with the driver */ 
 
My question is the next one : Does the driver support sending datas through SPI to external devices or not? If the answer is "yes", can I get help please? I think I initialize the SPI bus and device correctly and I'm sure that I call the correct functions because I print debug messages in the driver. If it can help, I attached my source code.
 
Thanks for the help and excuse me for the number of messages sent!
 
 

[-- Attachment #2: SPI Block Diagram.JPG --]
[-- Type: image/pjpeg, Size: 23924 bytes --]

[-- Attachment #3: spi.c --]
[-- Type: text/plain, Size: 2495 bytes --]

#include <stdio.h>
#include <cyg/hal/hal_diag.h>
#include <cyg/io/spi.h>
#include <cyg/io/spi_at91.h>
#include <cyg/io/spi_eb55.h>

#define DEV_NUM 5 //default 0
#define CL_POL 1 //default 1 //mode3=1
#define CL_PHA 1 //default 0 //mode3=1
#define CL_BRATE 10000 //default 8192000
#define CS_UP_UDLY 1 //default 1
#define CS_DW_UDLY 1 //default 1
#define TR_BT_UDLY 1 //default 1

cyg_spi_at91_device_t *spi_eb55_device;
cyg_spi_device *cyg_spi_eb55_device;

void echo_spi_at91_device(cyg_spi_at91_device_t dev);
cyg_spi_device *configure_spi_at91_device(cyg_spi_at91_device_t *dev);

int main()
{
    int i=0;
    cyg_uint8 tx_data_test;
    cyg_uint8 rx_data;
    
    printf("Entering application !\n");
    hal_diag_led(0x0);
    
    //HAL_WRITE_UINT32(0xFFFEC000, 0x01FC);
    
    cyg_spi_eb55_device = configure_spi_at91_device(spi_eb55_device);
    
    tx_data_test=0x55;
    
    printf("Sending data...\n");
    printf("1\n");
    cyg_spi_transaction_begin(cyg_spi_eb55_device);
    printf("2\n");
    while(1)
    {
        printf("%i\n",i++);
        printf("a\n");
        cyg_spi_transaction_transfer(cyg_spi_eb55_device, 0, 8, &tx_data_test, &rx_data, 0);
        cyg_spi_transaction_tick(cyg_spi_eb55_device, 0, 1);
        printf("b\n");
        //printf("Datas deceived : %i\n",rx_data);
    }
    
    /*cyg_spi_transaction_end(cyg_spi_eb55_device);*/
    
    printf("End of main !\n");
}

cyg_spi_device *configure_spi_at91_device(cyg_spi_at91_device_t *dev)
{
    echo_spi_at91_device(*dev);
    
    printf("Setting SPI AT91 device configuration...\n");
    dev->spi_device.spi_bus = &cyg_spi_at91_bus.spi_bus;
    dev->dev_num = DEV_NUM;
    dev->cl_pol = CL_POL;
    dev->cl_pha = CL_PHA;
    dev->cl_brate = CL_BRATE;
    dev->cs_up_udly = CS_UP_UDLY;
    dev->cs_dw_udly = CS_DW_UDLY;
    dev->tr_bt_udly = TR_BT_UDLY;
    printf("Configuration setted.\n");
    
    echo_spi_at91_device(*dev);
    
    return &dev->spi_device;
}

void echo_spi_at91_device(cyg_spi_at91_device_t dev)
{
    printf("Printing SPI AT91 device configuration :\n");
    printf("-  -------------\n");
    printf("-  dev_number  = %i\n",dev.dev_num);
    printf("-  cl_polarity = %i\n",dev.cl_pol);
    printf("-  cl_phase    = %i\n",dev.cl_pha);
    printf("-  cl_baudrate = %i\n",dev.cl_brate);
    printf("-  cs_up_udly  = %i\n",dev.cs_up_udly);
    printf("-  cs_dw_udly  = %i\n",dev.cs_dw_udly);
    printf("-  tr_br_udly  = %i\n",dev.tr_bt_udly);
    printf("-  -------------\n");
}

[-- Attachment #4: Type: text/plain, Size: 148 bytes --]

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [ECOS] Does AT91 SPI driver support external SPI devices?
  2007-02-28 14:05 ` [ECOS] Does AT91 SPI driver support external SPI devices? Julien Stéphane
@ 2007-02-28 14:43   ` Andrew Lunn
       [not found]     ` <F7620004260C5D4DB836EDBF8CC6872D028943B7@neptune.intra.eiaj.ch>
  0 siblings, 1 reply; 12+ messages in thread
From: Andrew Lunn @ 2007-02-28 14:43 UTC (permalink / raw)
  To: Julien St?phane; +Cc: ecos-discuss, nicolas.brouard, Etique Philippe

On Wed, Feb 28, 2007 at 03:04:10PM +0100, Julien St?phane wrote:
> Hi,
>  

> I still have problems to make SPI work on my AT91 evaluation
> board. I hava nothing to the SPI output of my AT91EB55 board
> (sniffing with scope). I've studied the datasheet of my processor
> and have seen the block diagram attached to this mail. Apparently,
> there are switches default openned to activate SPI signals.

> I didn't found in code where these switches are closed, so I have
> tried to write directly to the memory with HAL_WRITE_UINT32 to close
> them but no chages appears. Furthermore, I've studied the at91 SPI
> driver code and I have readed this comment in the function
> spi_at91_transaction_begin() :

>  
>     /* As we are using this driver only in master mode with NPCS0 
>        configured as GPIO instead of a peripheral pin, it is neccessary 
>        for the Mode Failure detection to be switched off as this will
>        cause havoc with the driver */ 

This is to work around a hardware bug. When the SPI peripheral drives
the NPCS lines, it gets it wrong for all but NPCS0. This is documented
in the errata somewhere. To work around this, the NPCS lines are set
as GPIO lines and controlled that way.
  
> My question is the next one : Does the driver support sending datas
> through SPI to external devices or not?

Well a number of people have reported it working, John Eigelaar,
Sebastian Block, Savin Zlobec.

> If the answer is "yes", can I get help please? I think I initialize
> the SPI bus and device correctly and I'm sure that I call the
> correct functions because I print debug messages in the driver. If
> it can help, I attached my source code.

O.K. Lets start with a silly question. Are you sure you are looking at
the correct pins. The pins used for NPCS are configurable by CDL. On
most AT91 devices, the peripheral devices can select between multiple
pins on the chip. Which pins do you have you logic analyze connected
to? Which pins is the SPI device driver using?

    Andrew

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ECOS] RE : [ECOS] Does AT91 SPI driver support external SPI devices?
       [not found]     ` <F7620004260C5D4DB836EDBF8CC6872D028943B7@neptune.intra.eiaj.ch>
@ 2007-02-28 15:07       ` Julien Stéphane
       [not found]       ` <20070228151737.GA14399@lunn.ch>
  1 sibling, 0 replies; 12+ messages in thread
From: Julien Stéphane @ 2007-02-28 15:07 UTC (permalink / raw)
  To: ecos-discuss

Thank you for your help! 
 
Indeed, I didn't checked the pins in CDL. So I use the default values : AT91_SPI_NPCS0, AT91_SPI_NPCS1, AT91_SPI_NPCS2, AT91_SPI_NPCS3. Is it correct or do I havt to chage it?
 
On my AT91 board, I connected the scope to the pins MOSI-GND and SCLK-GND, nothing on the analyzer. To check if a chip select was enabled, i measured voltage between GND and NSPICS5-8 and no CS were enabled. Nevertheless, I set the dev_num value of the cyg_spi_at91_device_t structure to the value 4-8. All voltages are to 3.3V and no CS is to 0V.

> O.K. Lets start with a silly question. Are you sure you are looking at
> the correct pins. The pins used for NPCS are configurable by CDL. On
> most AT91 devices, the peripheral devices can select between multiple
> pins on the chip. Which pins do you have you logic analyze connected
> to? Which pins is the SPI device driver using?
> 
>     Andrew

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ECOS] RE : RE?: [ECOS] Does AT91 SPI driver support external SPI devices?
       [not found]       ` <20070228151737.GA14399@lunn.ch>
@ 2007-02-28 15:34         ` Julien Stéphane
  2007-02-28 15:59           ` [ECOS] RE?: " Andrew Lunn
  0 siblings, 1 reply; 12+ messages in thread
From: Julien Stéphane @ 2007-02-28 15:34 UTC (permalink / raw)
  To: ecos-discuss; +Cc: andrew, Etique Philippe

I don't know how to put the correct value because my board (AT91EB55) use a BIN/OCT converter. So if I want to use the device 4, the value of NPCS0=0, NPCS1=0, NPCS2=1 and NPCS3=0.
 
The pins number of different NPCS are : NPCS0=pin98 (PA26), NPCS1=pin99 (PA27), NPCS2=pin100 (PA28) and NPCS3=pin101 (PA29).
 
What does the AT91_PIN(.., .., ..) mean? Do I have to devine the AT91_SPI_NPCS1 in my code or in the driver? I think in my code...
 
Regards,
Stéphane

________________________________

> Thank you for your help! Indeed, I didn't checked the pins in
> CDL. So I use the default values : AT91_SPI_NPCS0, AT91_SPI_NPCS1,
> AT91_SPI_NPCS2, AT91_SPI_NPCS3. Is it correct or do I havt to chage
> it?

You have to answer that by looking at the schematic of the board you
are using. Which pin on the chip is connected to the chip select of
your device? For example, on the AT91SAM7X, NPCS1 can be

#define AT91_SPI_NPCS1    AT91_PIN(0,0,13) // SPI 0 Chip Select 0
#define AT91_SPI_NPCS1X   AT91_PIN(0,1, 7) // SPI 0 Chip Select 1
#define AT91_SPI_NPCS1XX  AT91_PIN(1,1,13) // SPI 0 Chip Select 1

        Andrew



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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [ECOS] RE?: RE?: [ECOS] Does AT91 SPI driver support external SPI devices?
  2007-02-28 15:34         ` [ECOS] RE : RE?: " Julien Stéphane
@ 2007-02-28 15:59           ` Andrew Lunn
  2007-02-28 16:45             ` [ECOS] RE : " Julien Stéphane
  2007-02-28 17:13             ` [ECOS] RE : [ECOS] RE?: RE?: " Julien Stéphane
  0 siblings, 2 replies; 12+ messages in thread
From: Andrew Lunn @ 2007-02-28 15:59 UTC (permalink / raw)
  To: Julien St?phane; +Cc: ecos-discuss, andrew, Etique Philippe

On Wed, Feb 28, 2007 at 04:33:57PM +0100, Julien St?phane wrote:

> I don't know how to put the correct value because my board
> (AT91EB55) use a BIN/OCT converter. So if I want to use the device
> 4, the value of NPCS0=0, NPCS1=0, NPCS2=1 and NPCS3=0.

> The pins number of different NPCS are : NPCS0=pin98 (PA26),
> NPCS1=pin99 (PA27), NPCS2=pin100 (PA28) and NPCS3=pin101 (PA29).

The EB55 is actually an M55800A?

If so, its pins are not as flexible as the AT91SAM7 devices. There is
only one place the SPI pins come out of the chip.

> What does the AT91_PIN(.., .., ..) mean? Do I have to define the
> AT91_SPI_NPCS1 in my code or in the driver? I think in my code...

They are defined in var_io.h in the HAL. You can just use them in your
SPI configuration. The default values should be O.K.

I suggest you single step through spi_at91_set_npcs(). As it sets the
bits you should see the NPCS outputs from the chip change. Check what
is going into the demultiplexor and what is coming out of the
demultiplexor.

        Andrew

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ECOS] RE : [ECOS] RE?: RE?: [ECOS] Does AT91 SPI driver support external SPI devices?
  2007-02-28 15:59           ` [ECOS] RE?: " Andrew Lunn
@ 2007-02-28 16:45             ` Julien Stéphane
  2007-02-28 17:37               ` [ECOS] Re: RE?: " Andrew Lunn
  2007-02-28 17:13             ` [ECOS] RE : [ECOS] RE?: RE?: " Julien Stéphane
  1 sibling, 1 reply; 12+ messages in thread
From: Julien Stéphane @ 2007-02-28 16:45 UTC (permalink / raw)
  To: ecos-discuss; +Cc: andrew, Etique Philippe

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. So I have redefined this function :

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.

Thanks very much, Stéphane.

________________________________

On Wed, Feb 28, 2007 at 04:33:57PM +0100, Julien St?phane wrote:

> I don't know how to put the correct value because my board
> (AT91EB55) use a BIN/OCT converter. So if I want to use the device
> 4, the value of NPCS0=0, NPCS1=0, NPCS2=1 and NPCS3=0.

> The pins number of different NPCS are : NPCS0=pin98 (PA26),
> NPCS1=pin99 (PA27), NPCS2=pin100 (PA28) and NPCS3=pin101 (PA29).

The EB55 is actually an M55800A?

If so, its pins are not as flexible as the AT91SAM7 devices. There is
only one place the SPI pins come out of the chip.

> What does the AT91_PIN(.., .., ..) mean? Do I have to define the
> AT91_SPI_NPCS1 in my code or in the driver? I think in my code...

They are defined in var_io.h in the HAL. You can just use them in your
SPI configuration. The default values should be O.K.

I suggest you single step through spi_at91_set_npcs(). As it sets the
bits you should see the NPCS outputs from the chip change. Check what
is going into the demultiplexor and what is coming out of the
demultiplexor.

        Andrew


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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ECOS] RE : [ECOS] RE?: RE?: [ECOS] Does AT91 SPI driver support external SPI devices?
  2007-02-28 15:59           ` [ECOS] RE?: " Andrew Lunn
  2007-02-28 16:45             ` [ECOS] RE : " Julien Stéphane
@ 2007-02-28 17:13             ` Julien Stéphane
  2007-02-28 17:36               ` [ECOS] " Grant Edwards
  1 sibling, 1 reply; 12+ messages in thread
From: Julien Stéphane @ 2007-02-28 17:13 UTC (permalink / raw)
  To: ecos-discuss; +Cc: andrew, Etique Philippe

An other thing, when i tset the board with the Functionnal Test Software of Atmel, it tail that there is an error with USART. Can it be the source of my problems?
 
Thanks a lot!
Stéphane

________________________________

On Wed, Feb 28, 2007 at 04:33:57PM +0100, Julien St?phane wrote:

> I don't know how to put the correct value because my board
> (AT91EB55) use a BIN/OCT converter. So if I want to use the device
> 4, the value of NPCS0=0, NPCS1=0, NPCS2=1 and NPCS3=0.

> The pins number of different NPCS are : NPCS0=pin98 (PA26),
> NPCS1=pin99 (PA27), NPCS2=pin100 (PA28) and NPCS3=pin101 (PA29).

The EB55 is actually an M55800A?

If so, its pins are not as flexible as the AT91SAM7 devices. There is
only one place the SPI pins come out of the chip.

> What does the AT91_PIN(.., .., ..) mean? Do I have to define the
> AT91_SPI_NPCS1 in my code or in the driver? I think in my code...

They are defined in var_io.h in the HAL. You can just use them in your
SPI configuration. The default values should be O.K.

I suggest you single step through spi_at91_set_npcs(). As it sets the
bits you should see the NPCS outputs from the chip change. Check what
is going into the demultiplexor and what is coming out of the
demultiplexor.

        Andrew


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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ECOS]  Re: RE : [ECOS] RE?: RE?: [ECOS] Does AT91 SPI  driver support external SPI devices?
  2007-02-28 17:13             ` [ECOS] RE : [ECOS] RE?: RE?: " Julien Stéphane
@ 2007-02-28 17:36               ` Grant Edwards
  0 siblings, 0 replies; 12+ messages in thread
From: Grant Edwards @ 2007-02-28 17:36 UTC (permalink / raw)
  To: ecos-discuss

On 2007-02-28, Julien Stéphane <Stephane.Julien@he-arc.ch> wrote:

Re: RE : [ECOS] RE?: RE?: [ECOS] Does AT...

A few more layers of crud, and the real subject will be
completely off the screen...

-- 
Grant Edwards                   grante             Yow!  .. does your DRESSING
                                  at               ROOM have enough ASPARAGUS?
                               visi.com            


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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ECOS] Re: RE?: [ECOS] RE?: RE?: [ECOS] Does AT91 SPI driver support external SPI devices?
  2007-02-28 16:45             ` [ECOS] RE : " Julien Stéphane
@ 2007-02-28 17:37               ` Andrew Lunn
  2007-03-01 10:15                 ` [ECOS] RE : RE: RE: " Julien Stéphane
  0 siblings, 1 reply; 12+ messages in thread
From: Andrew Lunn @ 2007-02-28 17:37 UTC (permalink / raw)
  To: Julien St?phane; +Cc: ecos-discuss, andrew, Etique Philippe

On Wed, Feb 28, 2007 at 05:45:38PM +0100, Julien St?phane wrote:
> 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);
}

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ECOS] RE : RE: RE: RE: [ECOS] Does AT91 SPI driver support external SPI devices?
  2007-02-28 17:37               ` [ECOS] Re: RE?: " Andrew Lunn
@ 2007-03-01 10:15                 ` Julien Stéphane
  2007-03-01 13:04                   ` [ECOS] RE?: " Andrew Lunn
  0 siblings, 1 reply; 12+ messages in thread
From: Julien Stéphane @ 2007-03-01 10:15 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: Etique Philippe, ecos-discuss

[-- Attachment #1: Type: text/plain, Size: 3013 bytes --]

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 #2: SPI Block Diagram.JPG --]
[-- Type: image/pjpeg, Size: 23924 bytes --]

[-- Attachment #3: Type: text/plain, Size: 148 bytes --]

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [ECOS] RE?: RE: RE: RE: [ECOS] Does AT91 SPI driver support external SPI devices?
  2007-03-01 10:15                 ` [ECOS] RE : RE: RE: " Julien Stéphane
@ 2007-03-01 13:04                   ` Andrew Lunn
  2007-03-01 14:43                     ` Julien Stéphane
  0 siblings, 1 reply; 12+ messages in thread
From: Andrew Lunn @ 2007-03-01 13:04 UTC (permalink / raw)
  To: Julien St?phane; +Cc: Andrew Lunn, Etique Philippe, ecos-discuss

On Thu, Mar 01, 2007 at 11:15:17AM +0100, Julien St?phane wrote:
> 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.

O.K. That is good. It is one thing less to worry about.
 
> 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.

So you are saying that the input to the multiplexor is working as
expected, but the output from the multiplex is not? 
 
> 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?

Those are set via the HAL_ARM_AT91_GPIO_CFG_DIRECTION macro in the
function spi_at91_init_bus(). If the output from the processors is
working as expected, it means this cannot be the problem.

So it sounds like the multiplexor is the problem. Does it have a chip
select line? Do you need to set a jumper to enable it? 

       Andrew

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [ECOS] Does AT91 SPI driver support external SPI devices?
  2007-03-01 13:04                   ` [ECOS] RE?: " Andrew Lunn
@ 2007-03-01 14:43                     ` Julien Stéphane
  0 siblings, 0 replies; 12+ messages in thread
From: Julien Stéphane @ 2007-03-01 14:43 UTC (permalink / raw)
  To: Andrew Lunn, ecos-discuss; +Cc: Etique Philippe

[-- Attachment #1: Type: text/plain, Size: 2909 bytes --]

I thought too that the multiplexor had a problem. Following your concil, I read the evaluation user guide with more attention. There is no jumper but a line to cut (see attached). I cutted it and now, RedBoot doen't boot anymore on my board. Is RedBoot installed in the DataFlash memory? Here is my RedBoot version return : 
 
RedBoot> version
RedBoot(tm) bootstrap and debug environment [ROM]
Non-certified release, version UNKNOWN - built 20:04:38, Jul 15 2003
Platform: Atmel AT91/EB55 (ARM7TDMI) 
Copyright (C) 2000, 2001, 2002, Red Hat, Inc.
RAM: 0x02000000-0x02040000, 0x02006948-0x0203f000 available
FLASH: 0x01000000 - 0x01200000, 32 blocks of 0x00010000 bytes each.
RedBoot> 
 
PS:I installed a jumper to reclose this connection.
 
--
Stéphane JULIEN
 
Ing. dipl. HES en informatique
Rue Baptiste-Savoye 26
CH - 2610 Saint-Imier
Bureau : +41 32 930 22 08
Privé : +41 78 889 14 47
stephane.julien@he-arc.ch

________________________________

On Thu, Mar 01, 2007 at 11:15:17AM +0100, Julien St?phane wrote:
> 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.

O.K. That is good. It is one thing less to worry about.

> 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.

So you are saying that the input to the multiplexor is working as
expected, but the output from the multiplex is not?

> 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?

Those are set via the HAL_ARM_AT91_GPIO_CFG_DIRECTION macro in the
function spi_at91_init_bus(). If the output from the processors is
working as expected, it means this cannot be the problem.

So it sounds like the multiplexor is the problem. Does it have a chip
select line? Do you need to set a jumper to enable it?

       Andrew


[-- Attachment #2: CB9.JPG --]
[-- Type: image/pjpeg, Size: 18682 bytes --]

[-- Attachment #3: Type: text/plain, Size: 148 bytes --]

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2007-03-01 14:43 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <F7620004260C5D4DB836EDBF8CC6872D028943B5@neptune.intra.eiaj.ch>
2007-02-28 14:05 ` [ECOS] Does AT91 SPI driver support external SPI devices? Julien Stéphane
2007-02-28 14:43   ` Andrew Lunn
     [not found]     ` <F7620004260C5D4DB836EDBF8CC6872D028943B7@neptune.intra.eiaj.ch>
2007-02-28 15:07       ` [ECOS] RE : " Julien Stéphane
     [not found]       ` <20070228151737.GA14399@lunn.ch>
2007-02-28 15:34         ` [ECOS] RE : RE?: " Julien Stéphane
2007-02-28 15:59           ` [ECOS] RE?: " Andrew Lunn
2007-02-28 16:45             ` [ECOS] RE : " Julien Stéphane
2007-02-28 17:37               ` [ECOS] Re: RE?: " Andrew Lunn
2007-03-01 10:15                 ` [ECOS] RE : RE: RE: " Julien Stéphane
2007-03-01 13:04                   ` [ECOS] RE?: " Andrew Lunn
2007-03-01 14:43                     ` Julien Stéphane
2007-02-28 17:13             ` [ECOS] RE : [ECOS] RE?: RE?: " Julien Stéphane
2007-02-28 17:36               ` [ECOS] " Grant Edwards

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).