public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] SPI problem on AT91EB55
@ 2007-02-27  9:25 Julien Stéphane
  2007-02-27 10:09 ` Chris Zimman
  2007-02-27 21:28 ` [ECOS] " Nicolas Brouard
  0 siblings, 2 replies; 3+ messages in thread
From: Julien Stéphane @ 2007-02-27  9:25 UTC (permalink / raw)
  To: ecos-discuss; +Cc: Etique Philippe

Hy everybody,
 
I have problems for programming SPI on AT91EB55. I have plugged an oscilloscope to the corresponding pins of I/O extension connector and nothing come to the pins. Does it come from a driver problem or an error in code? I have checked the connections. Here is part of my code : 
 
------------------------------------------------------------------------------------------------------------
#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 4 //default 0
#define CL_POL 1 //default 1 / mode3=1
#define CL_PHA 1 //default 0 / mode3=1
#define CL_BRATE 3000000 //default 8192000, 2000000?, 3000000?
#define CS_UP_UDLY 1 //default 1
#define CS_DW_UDLY 1 //default 1
#define TR_BT_UDLY 1 //default 1
 
static cyg_spi_at91_device_t spi_eb55_device CYG_SPI_DEVICE_ON_BUS(DEV_NUM) = //CYG_SPI_DEVICE_ON_BUS(0)
{
    .spi_device.spi_bus = &cyg_spi_at91_bus.spi_bus,
    .dev_num     = DEV_NUM,          // Device number
    .cl_pol      = CL_POL,           // Clock polarity (0 or 1)
    .cl_pha      = CL_PHA,           // Clock phase (0 or 1)
    .cl_brate    = CL_BRATE,         // Clock baud rate
    .cs_up_udly  = CS_UP_UDLY,       // Delay in usec between CS up and transfer start
    .cs_dw_udly  = CS_DW_UDLY,       // Delay in usec between transfer end and CS down
    .tr_bt_udly  = TR_BT_UDLY        // Delay in usec between two transfers
};
 
cyg_spi_device *cyg_spi_eb55_device = &spi_eb55_device.spi_device;
 
int main(void)
{
    cyg_uint8 tx_data0, tx_data1, tx_data2, tx_data3;
    cyg_uint8 rx_data;
    
    printf("Entering application !\n");
    hal_diag_led(0x0);
    
    tx_data0=0x0;
    tx_data1=0x1;
    tx_data2=0x90;
    tx_data3=0x15;
        
    printf("Sending data...\n");
    cyg_spi_transfer(cyg_spi_eb55_device, 0, 1, &tx_data0, &rx_data);
    printf("Datas deceived : %i\n",rx_data);
    cyg_spi_transfer(cyg_spi_eb55_device, 0, 1, &tx_data1, &rx_data);
    printf("Datas deceived : %i\n",rx_data);
    cyg_spi_transfer(cyg_spi_eb55_device, 0, 1, &tx_data2, &rx_data);
    printf("Datas deceived : %i\n",rx_data);
    cyg_spi_transfer(cyg_spi_eb55_device, 0, 1, &tx_data3, &rx_data);
    printf("Datas deceived : %i\n",rx_data);
    
    cyg_spi_tick(cyg_spi_eb55_device, 0, 1000);
    
    printf("End of main !\n");
    //cyg_thread_exit();
}

--
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] 3+ messages in thread

* RE: [ECOS] SPI problem on AT91EB55
  2007-02-27  9:25 [ECOS] SPI problem on AT91EB55 Julien Stéphane
@ 2007-02-27 10:09 ` Chris Zimman
  2007-02-27 21:28 ` [ECOS] " Nicolas Brouard
  1 sibling, 0 replies; 3+ messages in thread
From: Chris Zimman @ 2007-02-27 10:09 UTC (permalink / raw)
  To: Julien Stéphane, ecos-discuss; +Cc: Etique Philippe

Julien,

As a first step, why don't you just see if you can get the chip select to toggle high/low?  If you can't get the driver to do this for you, I'm sure you can write a small piece of code quite easily to do it.

I don't know the AT91 in the level of detail to be able to look at this bit of code and see specifically what might be wrong, but you should make sure that the SPI interface is being initialized correctly (eg. trace spi_at91_transaction_begin() in 

packages/devs/spi/arm/at91/{your version}/src/spi_at91.c

In general, I would trace into there and see what's going on.  People here are more willing/likely to be able to help you with specific questions versus 'This doesn't work, what's wrong with my code?'

--Chris

-----Original Message-----
From: ecos-discuss-owner@ecos.sourceware.org [mailto:ecos-discuss-owner@ecos.sourceware.org] On Behalf Of Julien Stéphane
Sent: 27 February 2007 09:26
To: ecos-discuss@ecos.sourceware.org
Cc: Etique Philippe
Subject: [ECOS] SPI problem on AT91EB55

Hy everybody,
 
I have problems for programming SPI on AT91EB55. I have plugged an oscilloscope to the corresponding pins of I/O extension connector and nothing come to the pins. Does it come from a driver problem or an error in code? I have checked the connections. Here is part of my code : 
 
------------------------------------------------------------------------------------------------------------
#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 4 //default 0
#define CL_POL 1 //default 1 / mode3=1
#define CL_PHA 1 //default 0 / mode3=1
#define CL_BRATE 3000000 //default 8192000, 2000000?, 3000000?
#define CS_UP_UDLY 1 //default 1
#define CS_DW_UDLY 1 //default 1
#define TR_BT_UDLY 1 //default 1
 
static cyg_spi_at91_device_t spi_eb55_device CYG_SPI_DEVICE_ON_BUS(DEV_NUM) = //CYG_SPI_DEVICE_ON_BUS(0)
{
    .spi_device.spi_bus = &cyg_spi_at91_bus.spi_bus,
    .dev_num     = DEV_NUM,          // Device number
    .cl_pol      = CL_POL,           // Clock polarity (0 or 1)
    .cl_pha      = CL_PHA,           // Clock phase (0 or 1)
    .cl_brate    = CL_BRATE,         // Clock baud rate
    .cs_up_udly  = CS_UP_UDLY,       // Delay in usec between CS up and transfer start
    .cs_dw_udly  = CS_DW_UDLY,       // Delay in usec between transfer end and CS down
    .tr_bt_udly  = TR_BT_UDLY        // Delay in usec between two transfers
};
 
cyg_spi_device *cyg_spi_eb55_device = &spi_eb55_device.spi_device;
 
int main(void)
{
    cyg_uint8 tx_data0, tx_data1, tx_data2, tx_data3;
    cyg_uint8 rx_data;
    
    printf("Entering application !\n");
    hal_diag_led(0x0);
    
    tx_data0=0x0;
    tx_data1=0x1;
    tx_data2=0x90;
    tx_data3=0x15;
        
    printf("Sending data...\n");
    cyg_spi_transfer(cyg_spi_eb55_device, 0, 1, &tx_data0, &rx_data);
    printf("Datas deceived : %i\n",rx_data);
    cyg_spi_transfer(cyg_spi_eb55_device, 0, 1, &tx_data1, &rx_data);
    printf("Datas deceived : %i\n",rx_data);
    cyg_spi_transfer(cyg_spi_eb55_device, 0, 1, &tx_data2, &rx_data);
    printf("Datas deceived : %i\n",rx_data);
    cyg_spi_transfer(cyg_spi_eb55_device, 0, 1, &tx_data3, &rx_data);
    printf("Datas deceived : %i\n",rx_data);
    
    cyg_spi_tick(cyg_spi_eb55_device, 0, 1000);
    
    printf("End of main !\n");
    //cyg_thread_exit();
}

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

--
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] 3+ messages in thread

* [ECOS] RE: SPI problem on AT91EB55
  2007-02-27  9:25 [ECOS] SPI problem on AT91EB55 Julien Stéphane
  2007-02-27 10:09 ` Chris Zimman
@ 2007-02-27 21:28 ` Nicolas Brouard
  1 sibling, 0 replies; 3+ messages in thread
From: Nicolas Brouard @ 2007-02-27 21:28 UTC (permalink / raw)
  To: 'Julien Stéphane', ecos-discuss; +Cc: 'Etique Philippe'

Maybe try to reduce the baudrate. Use 50000 or 500000 instead of 3000000 to
see the signal easily with the scope.
Put an infinite loop to send data during a long time in order to be able to
setup your scope. 

Nicolas

-----Original Message-----
From: Julien Stéphane [mailto:Stephane.Julien@he-arc.ch] 
Sent: Tuesday, February 27, 2007 04:26
To: ecos-discuss@ecos.sourceware.org
Cc: Etique Philippe
Subject: SPI problem on AT91EB55

Hy everybody,
 
I have problems for programming SPI on AT91EB55. I have plugged an
oscilloscope to the corresponding pins of I/O extension connector and
nothing come to the pins. Does it come from a driver problem or an error in
code? I have checked the connections. Here is part of my code : 
 
----------------------------------------------------------------------------
--------------------------------
#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 4 //default 0
#define CL_POL 1 //default 1 / mode3=1
#define CL_PHA 1 //default 0 / mode3=1
#define CL_BRATE 3000000 //default 8192000, 2000000?, 3000000?
#define CS_UP_UDLY 1 //default 1
#define CS_DW_UDLY 1 //default 1
#define TR_BT_UDLY 1 //default 1
 
static cyg_spi_at91_device_t spi_eb55_device CYG_SPI_DEVICE_ON_BUS(DEV_NUM)
= //CYG_SPI_DEVICE_ON_BUS(0)
{
    .spi_device.spi_bus = &cyg_spi_at91_bus.spi_bus,
    .dev_num     = DEV_NUM,          // Device number
    .cl_pol      = CL_POL,           // Clock polarity (0 or 1)
    .cl_pha      = CL_PHA,           // Clock phase (0 or 1)
    .cl_brate    = CL_BRATE,         // Clock baud rate
    .cs_up_udly  = CS_UP_UDLY,       // Delay in usec between CS up and
transfer start
    .cs_dw_udly  = CS_DW_UDLY,       // Delay in usec between transfer end
and CS down
    .tr_bt_udly  = TR_BT_UDLY        // Delay in usec between two transfers
};
 
cyg_spi_device *cyg_spi_eb55_device = &spi_eb55_device.spi_device;
 
int main(void)
{
    cyg_uint8 tx_data0, tx_data1, tx_data2, tx_data3;
    cyg_uint8 rx_data;
    
    printf("Entering application !\n");
    hal_diag_led(0x0);
    
    tx_data0=0x0;
    tx_data1=0x1;
    tx_data2=0x90;
    tx_data3=0x15;
        
    printf("Sending data...\n");
    cyg_spi_transfer(cyg_spi_eb55_device, 0, 1, &tx_data0, &rx_data);
    printf("Datas deceived : %i\n",rx_data);
    cyg_spi_transfer(cyg_spi_eb55_device, 0, 1, &tx_data1, &rx_data);
    printf("Datas deceived : %i\n",rx_data);
    cyg_spi_transfer(cyg_spi_eb55_device, 0, 1, &tx_data2, &rx_data);
    printf("Datas deceived : %i\n",rx_data);
    cyg_spi_transfer(cyg_spi_eb55_device, 0, 1, &tx_data3, &rx_data);
    printf("Datas deceived : %i\n",rx_data);
    
    cyg_spi_tick(cyg_spi_eb55_device, 0, 1000);
    
    printf("End of main !\n");
    //cyg_thread_exit();
}



--
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] 3+ messages in thread

end of thread, other threads:[~2007-02-27 21:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-27  9:25 [ECOS] SPI problem on AT91EB55 Julien Stéphane
2007-02-27 10:09 ` Chris Zimman
2007-02-27 21:28 ` [ECOS] " Nicolas Brouard

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