Atsamd21e18 sercom spi ssd1306 problem

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

Hello,

I made a board based on atsamd21e18a and got an oled
following the ssd1306 exemple given in atmel studio, I can't have my oled working

I changed the oled configuration to:

#  define SSD1306_SPI                 SERCOM2
#  define CONFIG_SSD1306_FRAMEBUFFER

#  define SSD1306_DC_PIN              PIN_PA07
#  define SSD1306_RES_PIN             0
#  define SSD1306_CS_PIN              PIN_PA09

#  define SSD1306_SPI_PINMUX_SETTING  SPI_SIGNAL_MUX_SETTING_M
#  define SSD1306_SPI_PINMUX_PAD0     PINMUX_PA08D_SERCOM2_PAD0
#  define SSD1306_SPI_PINMUX_PAD1     PINMUX_UNUSED
#  define SSD1306_SPI_PINMUX_PAD2     PINMUX_UNUSED
#  define SSD1306_SPI_PINMUX_PAD3     PINMUX_PA15C_SERCOM2_PAD3

Mosi is on PA08 and sclk on PA15

I'm using the oled exemple code but nothing show up on the display

 

Am I missing something?  or my configuration is correct and I am having some hardware issues ?

 

Thank you in advance  

This topic has a solution.
Last Edited: Fri. Sep 22, 2017 - 11:29 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I do not like a mix of SERCOM and SERCOM-ALT (PA15 and PA08). Did you check real signals on oscilloscope?

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

I changed my design, now mosi is on PA08 ans sck on PA11

According to my pinout, I must use SPI_SIGNAL_MUX_SETTING_P right?

For now, my sck line is always low, I must have forgoten something, but don't know what

 

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

To set MOSI on PA08 and SCLK on PA11 you need to (briefly):

  • Make PA08 and PA11 outputs
  • Set the Peripheral Function Multiplexer for PA08 and PA11 (PMUX[n].bit.PMUXm=2  i.e. function C)
  • Enable the APM Clock for the SPI
  • Setup the SPI Clock source
  • Select the Pads used for MOSI, SCLK and SS (Set CTRLA.DOPO to 3 for MOSI on Pad[0], SCLK on Pad[3] and SS on PAD[2])

David (aka frog_jr)

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

Thanks for your answer, but isn't all that made by:

 

void configure_spi_master(void)
{
    struct spi_config config_spi_master;
    struct spi_slave_inst_config slave_dev_config;
    /* Configure and initialize software device instance of peripheral slave */
    spi_slave_inst_get_config_defaults(&slave_dev_config);
    slave_dev_config.ss_pin = SLAVE_SELECT_PIN;
    spi_attach_slave(&slave, &slave_dev_config);
    /* Configure, initialize and enable SERCOM SPI module */
    spi_get_config_defaults(&config_spi_master);
    config_spi_master.mode_specific.master.baudrate = 1000000UL;
    config_spi_master.mux_setting = SPI_SIGNAL_MUX_SETTING_M;
    /* Configure pad 0 for data in */
    config_spi_master.pinmux_pad0 = PINMUX_PA08C_SERCOM0_PAD0;
    /* Configure pad 1 as unused */
    config_spi_master.pinmux_pad1 = PINMUX_UNUSED;
    /* Configure pad 2 for data out */
    config_spi_master.pinmux_pad2 = PINMUX_UNUSED;
    /* Configure pad 3 for SCK */
    config_spi_master.pinmux_pad3 = PINMUX_PA11C_SERCOM0_PAD3;
    spi_init(&spi_oled, SERCOM0, &config_spi_master);
    
    spi_enable(&spi_oled);
}

And the call to spi_init at the end? 

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ploblem solved, I had hardware issues

 

I soldered another board, the oled is now working

I will invesigate my first board to figure out what is going wrong.

 

Thanks for the answers

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

 

How to properly post source code: http://www.avrfreaks.net/comment...