Skip to content

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

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

(TODO) YOUR NAME HERE
    (TODO) LinkedIn, personal website, twitter, etc.
Tested on: (TODO) MacBook Pro (14-inch, 2021), macOS Monterey 12.5.1

(TODO: Your README)

Include lab questions, screenshots, analysis, etc. (Remember, this is public, so don't put anything here you don't want to share with the world.)

Part 3: Talking LEDs

3.2)

Q1. Why is bit-banging impractical on your laptop, despite it having a much faster processor than the RP2040?

Ans: The laptop processor is not exactly designed for ‘bit-banging’. As processors have become faster in terms of overwhelming number-crunching brute force, the layers of software and hardware between the processor and the outside world have also grown in number and size. In response to the growing distance between processors and memory, PC-class processors keep many hundreds of instructions in-flight on a single core at once, which has drawbacks when trying to switch rapidly between hard real time tasks. That is why bit-banging is impractical to use on our laptops.

Q2. What are some cases where directly using the GPIO might be a better choice than using the PIO hardware?

Ans: A GPIO is capable of running general purpose software, which the PIO is not capable of doing. In this case, where the GPIO outweighs the PIO hardware.

Q3. How do you get data into a PIO state machine?

Ans: From the transmit FIFO buffer, we take one data item and place it in the output shift register (OSR). This data moves one word at a time (32 bits) from the FIFO to the OSR. The OSR is capable of shifting its data out, one or more bits at a time to further destinations.

Q4. How do you get data out of a PIO state machine?

Ans: The state machine needs to be told which GPIO or GPIOs to output to. There are four different pin groups which are used by different instructions in different situations. The GPIO also needs to be told that PIO is in control of it (GPIO function select). PIO can drive the ‘output enable’ line up and down programmatically using certain instructions.

Q5. How do you program a PIO state machine?

Ans: The RP2040 has two PIO blocks, each of them with four state machines. Each PIO block has a 32-slot instruction memory which is visible to the four state machines in the block. Our program needs to be loaded into this instruction memory before any of our state machines can run the program. Once the program is loaded, we find a free state machine and tell it to run our program. We can order multiple state machines to run the same program, or tell each state machine to run a different program. The state machine stalls if we don’t provide any data in the TX FIFO, for which it is waiting. We need to write a function to push the data into the TX FIFO. In this way, we can successfully program a PIO state machine.

Q6. 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?

Ans: In the example, the pio_sm_put_blocking() function is responsible at the lowest level for telling the PIO to set the LED to a new color. It takes its input from the pixel_rgb. It falls within the put_pixel() function. The put_pixel() function takes its arguments from another function urgb_u32(), which defines the RGB values of the colors to be displayed on the LED.

This function is being accessed using the puts() function. We pass pattern_table[] as an argument for this function. The pattern table lets us access various patterns in which we want our LEDs to blink. In each of these pattern functions, the put_pixel function is being calles. This leads to the color changing action which is required for our program to function.

Q7. What role does the pioasm “assembler” play in the example, and how does this interact with CMake?

Ans: We use the pioasm tool to convert the assembler code to binary. We use the CMake function to invoke the pioasm and add the generated header to the include path of our target. The actual function being used it pico_generate_pio_header(TARGETPIO_FILE).

3.3) Code Annotations

WS2812.C Code Annotation. The Annotation is done using comments in Green color.


embedded_c1


embedded_c2


embedded_c3


embedded_c4


embedded_c5


WS2821.PIO.H Code Annotation. The Annotation is done in comments with Green color.


embedded_h1


embedded_h2


embedded_h3


embedded_h4


embedded_h5


3.4) COLOR BY NUMBER

The following Excel file contains all the registers, values and adresses: EXCEL

3.5) MODELLING TIME


IMG_9064


IMG_9066


3.6 & 3.7) ZOOMING IN AND TIMING DIAGRAM


The following Excel file contains timing data for packet transfer to ws2812 module: EXCEL


  • Q1. What were some strengths/weaknesses of working with paper?

Ans: Usage of paper helps us make changes and annotations easily within the available material. We can depict the information using interactive signs and symbols such as arrows and circles, which help us grasp the concept later in the future. A disadvantage is that we may not have all the documentation available in paper format always. In such cases, making annotations on our laptop/PC is the best option.

  • Q2. What were some strengths/weaknesses of working with spreadsheets?

Ans: Spreadsheets help us arrange large chunks of data in an easy readable format. Data can also be autopasted using the prediction algorithms available on spreadsheets. The in-built formulae help us run calculations and functions on available datasets. However, spreadsheets can be a bit binding if one doesn't know how to unleash their full potential. One needs to learn the full extent of spreadsheet's capabilities to make optimum use of them.

  • Q3. How might you approach this task using other tools available to you?

Ans: I prefer making annotations on my laptop itself using comments in the code editor. This way, we have transferrable annotations for other users to refer along with the code, even in real time. Sometimes drawing timing diagrams on spreadsheets can be a bit tidious. In that case, I might use Draw.io to create graphs and tables in an easier fashion, just to get my point across successfully.


PART 4: BLINKENLIGHT IMPLEMENTATION


Untitled.mp4

Here is the folder containing the code files: CODE

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 72.5%
  • CMake 23.1%
  • Python 4.4%