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.

Parents
  • 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. 

    You should look at the backside of the nRF9160 DK what pins are occupied by the Development Kit. If you want to re-route them to the physical pins on the DK, check out Didrik's answer in this ticket for instructions on how to go about it. It seems like P0.26 is the only one that is used by the DK.

    By the way, you should not configure the pins in your source code (.c or .h files), hardware configurations should get done in DTS using an overlay file. Take a look at 1.2 Walkthrough for BME280 to get an intutition of how to go about this.

    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)

    It is always good practice to use the highest abstraction layer-->the Zephyr API. However, in the newest versions of NCS, the function gpio_pin_write() is no longer present. In the newest versions of NCS, you should use the function gpio_pin_set() to set the logical level of an output pin.

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

     Yes, these can be used when configuring the pin through gpio_pin_configure(). Take a look at the sample ncs\v1.4.0\zephyr\samples\bluetooth\hci_spi\src\main.c how to go about this:

    Best regards

    Simon

  • Hi Simon,

    Thanks for the feedback. I took your advice. for setting the input/out and writing to a pin. For now no error when building

    struct device *dev;
    dev = device_get_binding("GPIO_0");
    
    Digital write
    
    gpio_pin_set(dev,12,1);
    else gpio_pin_set(dev,12,0 );
    
    Setting the pin to input/output
    gpio_pin_configure(dev,25,GPIO_OUTPUT);
    gpio_pin_configure(dev,23,GPIO_INPUT);

    I have the pins in the overlay file. Do I need to go into the nrf9160......_common.dts and change something from  there or overlay will take care of that.

    &spi3 {
      compatible ="nordic,nrf_spim";
      current-speed = <115200> ;
      status = "ok";
      sck-pin = <13>;
      sda_pin = <12>;
      cs_pin = <11>;
      dc_pin = <21>;
      reset_pin = <22>;
      busy_pin = <23>;
      pnlon_pin = <24>;
      bs_pin = <25>;
      css_pin = <26>;
      label = "SPI_display"
      spi-max-frequency = <8000000>;
    };
    
    &gpio0 {
    status = "ok";	
    }

    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


    Also for gpio read I am using gpio_pin_get() . Lastly what is the function if there is for starting the serial communication. 

Reply
  • Hi Simon,

    Thanks for the feedback. I took your advice. for setting the input/out and writing to a pin. For now no error when building

    struct device *dev;
    dev = device_get_binding("GPIO_0");
    
    Digital write
    
    gpio_pin_set(dev,12,1);
    else gpio_pin_set(dev,12,0 );
    
    Setting the pin to input/output
    gpio_pin_configure(dev,25,GPIO_OUTPUT);
    gpio_pin_configure(dev,23,GPIO_INPUT);

    I have the pins in the overlay file. Do I need to go into the nrf9160......_common.dts and change something from  there or overlay will take care of that.

    &spi3 {
      compatible ="nordic,nrf_spim";
      current-speed = <115200> ;
      status = "ok";
      sck-pin = <13>;
      sda_pin = <12>;
      cs_pin = <11>;
      dc_pin = <21>;
      reset_pin = <22>;
      busy_pin = <23>;
      pnlon_pin = <24>;
      bs_pin = <25>;
      css_pin = <26>;
      label = "SPI_display"
      spi-max-frequency = <8000000>;
    };
    
    &gpio0 {
    status = "ok";	
    }

    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


    Also for gpio read I am using gpio_pin_get() . Lastly what is the function if there is for starting the serial communication. 

Children
Related