[SOLVED] - UC3A3 Xplained Board - SPI1 Master - No Clue

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

I have problems to get my SPI Master to work.

I am using the AT32UC3A3-XPLD-Evaluationboard with a STEVAL-MKI105V1 (http://www.st.com/web/en/catalog...).

This MEMS-board is connected to the header J1, which is for SPI1 of the AT32UC3A3256, more precise for SPI1 with NPCS[0].

The problem is I'm totally unexperienced with AVR32-Chips and using AVR Studio 6 with C-Code.

So I used the ASF-Guide for SPI, read all the posts here und studied the ASF-example-projects.

Nothing worked except for the CS, which goes low:

Here is my Code:

http://pastebin.com/CyZt59sS <- main-file

http://pastebin.com/bEXWvCnX <- uc3_a3_xplained.h

http://pastebin.com/QijbdE1U <- init.h

http://pastebin.com/mzZaJTGf <- conf_clock.h

 

Could someone tell me where I have done total bullshit? laugh

 

Thanks in advance

This topic has a solution.

---------------------------------------

Whatever, let's fuck with the Gods in person.
 

Last Edited: Mon. Feb 1, 2016 - 01:20 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I don't see where you configure the GPIO multiplexing for the SPI module.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thx for the answer.

Isn't GPIO multiplexing this stuff with _PIN and _FUNCTION?

I did this in init.h which will be called from board_init():

  static const gpio_map_t spi1_gpio_map = {

                {HeaderJ1_SPI_SCK_PIN, HeaderJ1_SPI_SCK_FUNCTION},        //SCK

                {HeaderJ1_SPI_MISO_PIN, HeaderJ1_SPI_MISO_FUNCTION}, //MISO

                {HeaderJ1_SPI_NPCS0_PIN, HeaderJ1_SPI_NPCS0_FUNCTION}, //SS

                {HeaderJ1_SPI_MOSI_PIN, HeaderJ1_SPI_MOSI_FUNCTION}}; //MOSI

                gpio_enable_module(spi1_gpio_map,sizeof(spi1_gpio_map)/sizeof(spi1_gpio_map[0]));

The HeaderJ1_SPI-Variables are defined in uc3_a3_xplained.h

#define HeaderJ1_SPI                 (&AVR32_SPI1)

#define HeaderJ1_SPI_NPCS            0

#define HeaderJ1_SPI_SCK_PIN         AVR32_SPI1_SCK_0_0_PIN

#define HeaderJ1_SPI_SCK_FUNCTION    AVR32_SPI1_SCK_0_0_FUNCTION

#define HeaderJ1_SPI_MISO_PIN        AVR32_SPI1_MISO_0_0_PIN

#define HeaderJ1_SPI_MISO_FUNCTION   AVR32_SPI1_MISO_0_0_FUNCTION

#define HeaderJ1_SPI_MOSI_PIN        AVR32_SPI1_MOSI_0_0_PIN

#define HeaderJ1_SPI_MOSI_FUNCTION   AVR32_SPI1_MOSI_0_0_FUNCTION

#define HeaderJ1_SPI_NPCS0_PIN       AVR32_SPI1_NPCS_0_0_PIN

#define HeaderJ1_SPI_NPCS0_FUNCTION  AVR32_SPI1_NPCS_0_0_FUNCTION

---------------------------------------

Whatever, let's fuck with the Gods in person.
 

Last Edited: Fri. Jul 31, 2015 - 10:10 AM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For all who are searching like me, here is my working project:

uc3_a3_xplained.h ==> http://pastebin.com/A4EjTbwH

init.c ==> http://pastebin.com/ceEparaG

main.c ==> http://pastebin.com/EarX7f12

 

the important part in uc3_a3_xplained.h is:

/** \name Header J1 SPI1
 * @{
 */
#define HeaderJ1_SPI                 (&AVR32_SPI1)
#define HeaderJ1_SPI_NPCS            0
#define HeaderJ1_SPI_SCK_PIN         AVR32_SPI1_SCK_0_0_PIN
#define HeaderJ1_SPI_SCK_FUNCTION    AVR32_SPI1_SCK_0_0_FUNCTION
#define HeaderJ1_SPI_MISO_PIN        AVR32_SPI1_MISO_0_0_PIN
#define HeaderJ1_SPI_MISO_FUNCTION   AVR32_SPI1_MISO_0_0_FUNCTION
#define HeaderJ1_SPI_MOSI_PIN        AVR32_SPI1_MOSI_0_0_PIN
#define HeaderJ1_SPI_MOSI_FUNCTION   AVR32_SPI1_MOSI_0_0_FUNCTION
#define HeaderJ1_SPI_NPCS0_PIN       AVR32_SPI1_NPCS_0_0_PIN        // Verwendeter NPCS auf SS-Pin
#define HeaderJ1_SPI_NPCS0_FUNCTION  AVR32_SPI1_NPCS_0_0_FUNCTION
#define HeaderJ1_SPI_NPCS1_PIN       AVR32_SPI1_NPCS_1_0_PIN
#define HeaderJ1_SPI_NPCS1_FUNCTION  AVR32_SPI1_NPCS_1_0_FUNCTION
#define HeaderJ1_SPI_NPCS2_PIN       AVR32_SPI1_NPCS_2_0_PIN
#define HeaderJ1_SPI_NPCS2_FUNCTION  AVR32_SPI1_NPCS_2_0_FUNCTION
#define HeaderJ1_SPI_NPCS3_PIN       AVR32_SPI1_NPCS_3_PIN
#define HeaderJ1_SPI_NPCS3_FUNCTION  AVR32_SPI1_NPCS_3_FUNCTION
/** @} */

in init.c it is:

    static const gpio_map_t spi1_gpio_map = {
        {HeaderJ1_SPI_SCK_PIN, HeaderJ1_SPI_SCK_FUNCTION},        //SCK
        {HeaderJ1_SPI_MISO_PIN, HeaderJ1_SPI_MISO_FUNCTION}, //MISO
        {HeaderJ1_SPI_MOSI_PIN, HeaderJ1_SPI_MOSI_FUNCTION}, //MOSI
        {HeaderJ1_SPI_NPCS0_PIN, HeaderJ1_SPI_NPCS0_FUNCTION}, //SS
        {HeaderJ1_SPI_NPCS1_PIN, HeaderJ1_SPI_NPCS1_FUNCTION}, //SS
        {HeaderJ1_SPI_NPCS2_PIN, HeaderJ1_SPI_NPCS2_FUNCTION}, //SS
        {HeaderJ1_SPI_NPCS3_PIN, HeaderJ1_SPI_NPCS3_FUNCTION}}; //SS
        gpio_enable_module(spi1_gpio_map,sizeof(spi1_gpio_map)/sizeof(spi1_gpio_map[0]));

 

I hope my code is helpful, have a nice day and feel free to ask me via private message.

---------------------------------------

Whatever, let's fuck with the Gods in person.