Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

How to use

Altera_Forum
Honored Contributor II
2,448 Views

i m using alt_avalon_spi_command() now, and i did it according to Altera Embedded Peripherals Handbook chapter 7. I m looking using SPI to transfer some data to another board. And i can't figure out how to use this command line.  

 

int alt_avalon_spi_command(alt_u32 base, alt_u32 slave,  

alt_u32 write_length, const alt_u8* wdata, alt_u32 read_length,  

alt_u8* read_data, alt_u32 flags) 

 

1) Where can i find what value i should put for alt_u32 slave?  

2) What value should i put for flag?  

3) If i m going to just send the data, in MOSI mode, what value should i put for read_length and read_data? 

4) do you have an example demostrating how to use this command ? 

I just can't get it to work on Nios II cyclone board. 

 

how is i wrote the code  

 

_______________________________________________________ 

/*  

alt_u8 sending[16] = { 

0x81, 0xCF, 0x92, 0x86, 0xCC, 0xA4, 0xA0, 0x8F, 0x80, 0x84,  

0x88, 0xE0, 0xF2, 0xC2, 0xB0, 0xB8 };  

 

alt_u8 receiving[16]; 

 

download= alt_avalon_spi_command(0x00800000,1,16, sending,16, receiving,1);  

_______________________________________________________ 

 

and the output has no signal coming out. I can't figure out anything goes wrong.
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
1,202 Views

 

--- Quote Start ---  

originally posted by wei_chen0428@Mar 14 2006, 05:06 AM 

int alt_avalon_spi_command(alt_u32 base, alt_u32 slave,  

alt_u32 write_length, const alt_u8* wdata,  alt_u32 read_length,  

alt_u8* read_data, alt_u32 flags) 

 

1) where can i find what value i should put for alt_u32 slave?  

2) what value should i put for flag?  

3) if i m going to just send the data, in mosi mode, what value should i put for read_length and read_data? 

4) do you have an example demostrating how to use this command ? 

 

<div align='right'><{post_snapback}> (index.php?act=findpost&pid=13399) 

--- quote end ---  

 

--- Quote End ---  

 

May You see source code of "altera_avalon_spi.c" ? 

If you can do it you can find out function alt_avalon_spi_command. 

And see all information about this function and its variables. 

I recommend you read manual about SPI in SOPC builder
0 Kudos
Altera_Forum
Honored Contributor II
1,202 Views

 

--- Quote Start ---  

originally posted by wei_chen0428@Mar 14 2006, 05:06 AM 

int alt_avalon_spi_command(alt_u32 base, alt_u32 slave,  

alt_u32 write_length, const alt_u8* wdata,  alt_u32 read_length,  

alt_u8* read_data, alt_u32 flags) 

 

1) where can i find what value i should put for alt_u32 slave?  

2) what value should i put for flag?  

3) if i m going to just send the data, in mosi mode, what value should i put for read_length and read_data? 

4) do you have an example demostrating how to use this command ? 

 

<div align='right'><{post_snapback}> (index.php?act=findpost&pid=13399) 

--- quote end ---  

 

--- Quote End ---  

 

 

1. alt_u32 slave is the number of slave connected to your master, with the first one starting from "0", as pointed out in the documentation. 

 

2. Flag = ALT_AVALON_SPI_COMMAND_MERGE, if you wish to use that function, else put 0.
0 Kudos
Altera_Forum
Honored Contributor II
1,202 Views

 

--- Quote Start ---  

[/b] 

--- Quote End ---  

 

 

1. alt_u32 slave is the number of slave connected to your master, with the first one starting from "0", as pointed out in the documentation. 

 

 

So if I have 4 slaves connected to the SPI master, I should set slave =0x03? I think this argument is used to select which slave I want to write or read, e.g.: if I want to read or write slave 0, I should set slave = 0x00, correct? 

 

Thanks.
0 Kudos
Reply