Presentation is loading. Please wait.

Presentation is loading. Please wait.

Workshop GPIO I2C SPI Panic1 woensdag 10 april 2019.

Similar presentations


Presentation on theme: "Workshop GPIO I2C SPI Panic1 woensdag 10 april 2019."— Presentation transcript:

1 Workshop GPIO I2C SPI Panic1 woensdag 10 april 2019

2 Installing the Raspberry Pi
NOOBS NOOBS is an installer that packs a number of RPi ready images, easy to use, but you need an SD card of at least 8Gb to have enough room left for Raspbian Raspbian Debian image for Raspbery Pi © Sioux Embedded Systems 2011 | Confidential |

3 Installing NOOBS Format the SD card into one FAT32 partition
Extract the files in the tar ball onto the SD card Pop the SD card into the RPi and turn it on Select the image to install and you are ready Also easy to reinstall an image after it has been messed up, by pressing Shift during startup of the RPi and redo the installation © Sioux Embedded Systems 2011 | Confidential |

4 Installing Raspbian Format the SD card into one FAT32 partition
Use an image writing tool to write the downloaded image to the SD card Plug the SD card into the RPi and start it up © Sioux Embedded Systems 2011 | Confidential |

5 Documentation on RPi http://www.raspberrypi.org/documentation/
© Sioux Embedded Systems 2011 | Confidential |

6 GPIO via command line > sudo su > echo "22" > /sys/class/gpio/export > echo "out" > /sys/class/gpio/gpio22/direction > echo "1" > /sys/class/gpio/gpio22/value > echo "0" > /sys/class/gpio/gpio22/value > while true; \ > do echo "1" > /sys/class/gpio/gpio22/value; \ > echo "0" > /sys/class/gpio/gpio22/value; \ > done > echo "22" > /sys/class/gpio/unexport Source: © Sioux Embedded Systems 2011 | Confidential |

7 GPIO in a C program Download and unpack the cross compiler ( Download and unpack Eclipse ( Create new C Project Executable, Empty Project, Cross GCC Cross compiler prefix: “arm-bcm2708hardfp-linux-gnueabi-” Path to cross compiler: ~/workshop\ rasberry\ pi/cross-compiler/tools-master/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/bin New source file, copy-paste from Ctrl-B to Build the project © Sioux Embedded Systems 2011 | Confidential |

8 About the GPIO program This piece of C code doesn’t use a library, instead it mmaps the device memory, and manipulates the GPIO registers directly Must be run as root, to activate the root account on Raspbian: sudo passwd Don’t change the ssh config, make sure the root account stays permitted to login via ssh, we will need this in the later steps when running applications from Eclipse on the RPi target machines © Sioux Embedded Systems 2011 | Confidential |

9 Running the GPIO program
Selec the menu Run Run configurations C/C++ Remote Applications Create a new connection to your RPi board Don’t forget to generate a ssh key and install it on the RPi Go to menu Window, Preferences, General, Network Connections, SSH2 If all is well, you can now instruct Eclipse to copy and run the cross compiled program on the target machine © Sioux Embedded Systems 2011 | Confidential |

10 GPIO via CLI, two threads running concurrently on different GPIO pins
© Sioux Embedded Systems 2011 | Confidential |

11 I2C background Source: © Sioux Embedded Systems 2011 | Confidential |

12 I2C by using bcm2835 library Download to the RPi: Untar the file, and cd into the folder ./configure sudo make check sudo make install Getting these files into your cross compiler Copy bcm /src/bcm2835.o and libbcm2835.a from RPi to ~/workshop\ rasberry\ pi/cross-compiler/tools-master/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/arm-bcm2708hardfp-linux-gnueabi/sysroot/lib You will also need the header file (untar the same tar ball somewhere on your machine locally) © Sioux Embedded Systems 2011 | Confidential |

13 I2C example from bcm2835 lib We’ll be using the examples provided in the bcm2835 library package Create a new Eclipse project, same cross compiler settings as before To be able to use the lib in Eclipse, right click on Project, select Properties, C/C++ General, Paths and Symbols, Libraries tab, add "bcm2835", and in the Includes Tab, add the path to the bcm2835.h file Copy the i2c.c file into the project, build the project, and run the application like before on the RPi This time the application won’t work without arguments, try: ./I2cWorkshop -s85 -dw -ib 1 0x01 What are looking at on the scope? Either use the hold function, or put the program in a while(1) loop to see the signal. Don’t forget to run the application with option –ie to restore the I2C lines back to GPIO at the end © Sioux Embedded Systems 2011 | Confidential |

14 I2C: Trying to write to address 0x55, but no response
© Sioux Embedded Systems 2011 | Confidential |

15 SPI background Typical use: Typical use with three slave devices:
Daisy chained with three slave devices: Source: © Sioux Embedded Systems 2011 | Confidential |

16 SPI via bcm2835 library Use the example spi.c file from the bcm2835 library package Same as before, create a new cross gcc project in Eclipse, add the library to the project options, copy the file into the project Connect the MOSI and the SCLK signals to the scope. The CE0 signal is also interesting © Sioux Embedded Systems 2011 | Confidential |

17 PWM via the bcm2835 library Use the example pwm.c file from the library package Same as before Connect pin 12 (GPIO18) to the scope for the PWM signal © Sioux Embedded Systems 2011 | Confidential |

18 Thank you! © Sioux Embedded Systems 2011 | Confidential |


Download ppt "Workshop GPIO I2C SPI Panic1 woensdag 10 april 2019."

Similar presentations


Ads by Google