This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
RE: SPI problem on AT91EB55
- From: "Nicolas Brouard" <nicolas dot brouard at silicomp dot ca>
- To: 'Julien Stéphane' <Stephane dot Julien at he-arc dot ch>, <ecos-discuss at ecos dot sourceware dot org>
- Cc: "'Etique Philippe'" <Philippe dot Etique at he-arc dot ch>
- Date: Tue, 27 Feb 2007 16:33:33 -0500
- Subject: [ECOS] RE: SPI problem on AT91EB55
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