usart_spi_init() and usart_init_spi() in XMEGA B1 Xplained Demo Why?

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

I have been trying to setup my XMEGA-B1 Xplained board to read an iC Hauss iC iC-TW11 rotary encoder.  I am starting off with the B1 Xplained board and since that has an Atmel 45DB642DB EEPROM onboard and talks to it using USART SPI I thought I would try to leverage off the demo code. 

 

I am using Atmel Studio 7 with an Atmel ICE.  

 

Unfortunately the demo application gets stuck somewhere and doesn't run properly.  It would have been nice to have code that is not broken to have confidence that what I copy can be made to work. 

 

I have been trying to understand how the SPI is set up, but digging through file after file of #defines and #ifdefs to see how the Xplained board is setup to use the upper nibble of the C port etc. I have got quite bamboozled. 

 

I have seen posts to this forum of people sorting this out but they tend to have started from scratch.  I would have liked to keep the same framework as the example.

 

When the demo board arrived it did run with the firmware that was already loaded.  When I ran the debugger with the code from the example demo it was broken.

 

I can see in usart_spi.c there is a function usart_spi_setup_device() that looks like it might setup the stuff properly, and in there there is a call to usart_init_spi() which looks like it also does something useful to set up things correctly.  However both of those things are never used in the demo.

 

This is my first time using any of this.  I have used in circuit emulators sporadically over the years but I am far from being an expert at anything.

 

Anyone with any clues?  

 

 

 

 

 

 

 

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

I don't have an XMega-B1 Xplained board, but it would be helpful for others to know what the full title of the example demo you selected in the as AS7 dropdown is.  Is it "Unit Tests for the XMEGA SPI Driver - XMEGA-B1 Xplained"?

 

 

EDIT: deleted follow on question
​EDIT2: added it back for thread continuity

"I may make you feel but I can't make you think" - Jethro Tull - Thick As A Brick

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius

Last Edited: Mon. Dec 18, 2017 - 11:13 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That was quick.

 

The name of the example project is: XMEGA B1 Xplained demo application

 

Sorry, I didn't see those Unit test things.  I'll try the: Unit Test for the Common AT45DBX DataFlash Component - XMEGA-B1 Xplained

 

If that works I should be OK

 

Thanks heaps

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

usart_spi_init(USART_t* usart) does nothing more than enable the peripheral clock for the appropriate USART.

 

usart_init_spi(USART_t* usart, usart_spi_options_t *opt) actually configures the USART to act as a Master SPI, including enabling the peripheral clock, although it does that using a call to sysclk_enable_peripheral_clock(usart) rather than calling usart_spi_init().

 

Welcome to the Wonderful World of ASF!!

 

 

EDIT: as to why this is so, only Atmel knows for sure...

Greg Muth

Portland, OR, US

Atmel Studio 7 (Version: 7.0.1652) on Windows 10

Xplained/Pro/Mini Boards mostly

 

 

Last Edited: Mon. Dec 18, 2017 - 10:24 PM