Skip to content

essaalk/ese5190-2022-lab2-into-the-void-star

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

University of Pennsylvania, ESE 5190: Intro to Embedded Systems, Lab 2A

# Essa Alkhunayn

https://www.linkedin.com/in/eng-essa-alkhunayn-pmp%C2%AE-21327b14b/
  
    
Tested on: LENOVO_MT_80WK_BU_idea_FM_Y520-15IKBN - OS Name	Microsoft Windows 10 Home - System Type	x64-based PC

the PIOASM and ws2812.c file

To explain this code to any other user, I have placed comments next to the lines to explain their functionality."ws2812.pio.h" file is generated by the pioasm which is included in the final C code("ws2812.c"), the ws2182_program_init() helps us configure the pio moduel from the C code. On the far right of the window, we can follow the counter to see in what sequence the code runs, the up and down directions merely point where the next counter increment is. we have assumed that from the random pattern the code selects the random pattern.

image

image

image

image

Use of PIO module on RP2040

1-Why is bit-banging impractical on your laptop, despite it having a much faster processor than the RP2040? In today Pc although the processing power is much greater than RP2040, the layers of software and hardware between the processor and the outside world have also grown in number and size. Therefore it is difficult to obtain precise timing for hard real time applications. Incase of RP2040, it has a dedicated hardware called as the PIO, which runs separately, and hence it makes more sense to do bit-banging on this small microcontroller.

2- What are some cases where using GPIO might be a better option than using PIO devices? In cases where no precise outputs are needed. GPIO can be used to control things that need separate signals and don't rely on real-time processing like status indicators. It can also be used in a closed-loop system such as PWM.

3- How do you get the data in the PIO state device? To put the data into a PIO state device, we need to put the data into the FIFO_TXn register of the given PIO state device. We do this in a C file, and we can push the data directly using the "pio_sm_put_blocking()" helper function. This function checks if the FIFO feature is full and waits for data to be placed in it until it is empty.

4- How do you get data from the PIO state device? To get the data from the PIO state device, we first need to write a pio code, where when we execute the 'out' statement, the data is written to the specific pin mentioned in that statement.

5-How do you program a PIO state machine? To program a PIO state device, we need to create a .pio file, using the assembly instructions given in the RP2040 datasheet, we can program the exact pin behavior we need. Once the behavior is programmed, we need to add the state machine configuration in the same file then we need to edit the Cmake file and "ico_generate_pio_header()" to create a .pio.h file which can be used in C code to send data to the state machine.

6-In the example, which low-level C SDK function is directly responsible for telling the PIO to set the LED to a new color? How is this function accessed from the main “application” code? pio_sm_put_blocking(pio,sm,data) is a helper function which is directly responsible for telling the PIO to set LED to a new color. This function is accessed through the inline “put_pixel(data)” function.

7-What role does the pioasm “assembler” play in the example, and how does this interact with CMake? When we run the Pioasm, it will it will create some static variables describing the program, and a method ws2812_default_program_config which configures PIO state machine based on user parameters, and the directives in the actual PIO program. To invoke the pioasm we need to call “pico_generate_pio_header” which will create an “.h” header file, which is already included in out code.

Spreadsheet of Initial PIO Register States

Drive link to the spreadsheet - https://docs.google.com/spreadsheets/d/1v-5flhdtm8m_76C8Aig0-hozPYN_lp9LQVL06rwW4Co/edit?usp=sharing (Sheet 1)

Paper Modelling of the Code

image

image

image

Packet Transmission Spreadsheet

Image link to Packet Transmission Timing Diagram - https://ibb.co/Zg1Fg4H (Please download the PNG file and Zoom to see the waveform) Spreadsheet Link - https://docs.google.com/spreadsheets/d/1h2cIcP2sgUzOSQJtkfA_R5-FZlRSPOEY/edit?usp=sharing&ouid=117925605607785787119&rtpof=true&sd=true

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published