This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

e-paper display with spi. (hardware pins - digital write -baud-rate)

Hello,

Sorry if it will be long. thanks for the help.

Using nrf9160 dk. The first thing I want to ask is about is the pins. I want to make sure I am using the correct pin. I think most of the pins can be used for digital I/O so that leave the sck,MISO.MOSI. 

#define sck_pin   13     //p.13
#define sda_pin   12     //p.12   MISO
#define cs_pin    11     //p.11   MOSI
#define dc_pin    21     //       digital pin pwd   
#define reset_pin 22     //       digital pin pwd
#define busy_pin  23     //       digital pin pwd
#define pnlon_pin 24     //       digital pin pwd
#define bs_pin    25     //       digital pin pwd
#define css_pin   26     //       digital pin pwd

The second thing is that I am trying to digital write to pin high/low. similar to the Arduino digital write(). So I looked and found  nrf_gpio_pin_write ( uint32_t pin_number, uint32_t value ) OR  should use gpio_pin_write(struct device *port, gpio_pin_t pin, u32_t value)

Also to set-up a pin to output/input  GPIO_INPUT /  GPIO_OUTPUT can be used right.

Last question to begin the serial link I couldn't find anything about that except for spi_cfg.frequency = 115200;  but that doesn't work.


I looked also into the blinky example and devicetree still confused.

  • It guess it should work to use GPIOs to communicate with the display, by emulating SPI, but that makes everything much more complex and ineficcient. Instead of writing one line using the SPI peripheral, maybe you end up with 10 lines using the GPIOs instead.

    spi_loop.zip

    Test out the sample above with the nrf9160dk. It is a loopback sample where the nRF9160 both sends and receives data (to itself). Connect  P0.11 and P0.12 together to enable the loopback.

    When you get that to work, you know how to both send and receive data with SPI, which is all you need. Then you can modify it to communicate with the Display. You should study the datasheet of your display of how to communicate with it.

    AMG said:
    Other issue the printk is not printing does that mean the code is running?? 

    That might be, but you don't know for certain. It may be something wrong with how you set up the logging. Test out the sample zephyr/samples/hello_world, and open a termite terminal with these setting:

    Best regards,

    Simon

  • I appreciate all the help, will give it a try. One last thing can you do a quick check and try to see if you can spot anything wrong with the config files or I need to add something to the dts files before I start with a different approach. 

      pin connections (sck: p0.13- MISO p0.12 -  MOSI p0.11 ) ( From p0.20   to p0.25 digital pwm pins) 




    prj.conf

    CONFIG_SPM=y
    CONFIG_TRUSTED_EXECUTION_NONSECURE=y
    CONFIG_STDOUT_CONSOLE=y
    CONFIG_LOG=y
    CONFIG_LOG_DEFAULT_LEVEL=4
    CONFIG_HEAP_MEM_POOL_SIZE=16384
    
    
    # SPI
    
    CONFIG_SERIAL=y
    CONFIG_SPI=y
    CONFIG_SPI_3=y
    #CONFIG_SPI_SLAVE =y
    #CONFIG_SPI_3_NRF_SPIM=y
    CONFIG_SPI_3=y 
    CONFIG_SPI_NRFX=y
    #CONFIG_SPI_3_OP_MODES =y
    CONFIG_MAIN_STACK_SIZE=4096
    
    
    
    #GPIO
    
    CONFIG_GPIO=y
    CONFIG_PRINTK=y
    CONFIG_LOG_PRINTK=y



    overlay

    &spi3 {
      status = "ok"; 
      current-speed = <115200> ;
      sck-pin = <13>;
      miso_pin = <12>;
      mosi_pin = <11>;
      label = "SPI_3";
    };
    
    &gpio0 {
    status = "ok";	
    };



    Pin connection. 

    #define SCK_pin   13     //p.13
    #define MISO_pin   12     //p.12   MISO
    #define MOSI_pin    11     //p.11   MOSI
    #define DC_pin    20     // p0.20       digital pin pwm   
    #define RESET_pin 21     //  p0.21     digital pin pwm
    #define BUSY_pin  22     // p0.22      digital pin pwm
    #define PNLON_pin 23     // p0.23      digital pin pwm
    #define BS_pin    24     // p0.24       digital pin pwm
    #define CSS_pin   25     // po.25      digital pin pwm

  • I Managed to get it to work. Thanks for all your help Simon. 

Related