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: SPI problem on AT91EB55


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


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