Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LAB 2A: Sen Luo #58

Open
wants to merge 77 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
60942ef
Update README.md
SEN316 Oct 14, 2022
d54cbcb
Update README.md
SEN316 Oct 14, 2022
457b4bf
Update README.md
SEN316 Oct 14, 2022
ee5bf91
Update README.md
SEN316 Oct 14, 2022
8b22a77
Update README.md
SEN316 Oct 14, 2022
d35fe18
Update README.md
SEN316 Oct 14, 2022
1d1c5c0
Update README.md
SEN316 Oct 14, 2022
45edd92
Update README.md
SEN316 Oct 14, 2022
250f41a
Update README.md
SEN316 Oct 14, 2022
5f4b3a9
Add files via upload
SEN316 Oct 14, 2022
e4c3ab2
Delete 微信图片_20221014054300.png
SEN316 Oct 14, 2022
5b5466a
Delete 微信图片_20221014054205.png
SEN316 Oct 14, 2022
aa7461c
Add files via upload
SEN316 Oct 14, 2022
08cb91c
Add files via upload
SEN316 Oct 14, 2022
1204f4a
Add files via upload
SEN316 Oct 14, 2022
8286f70
Add files via upload
SEN316 Oct 14, 2022
c1611cd
Update README.md
SEN316 Oct 14, 2022
0a1f930
Add files via upload
SEN316 Oct 14, 2022
9ea297c
Update README.md
SEN316 Oct 14, 2022
be8f716
Update README.md
SEN316 Oct 14, 2022
24a9698
Update README.md
SEN316 Oct 14, 2022
c529753
Update README.md
SEN316 Oct 14, 2022
08a5f8f
Update README.md
SEN316 Oct 14, 2022
f4b18be
Update README.md
SEN316 Oct 14, 2022
b79cedd
Update README.md
SEN316 Oct 14, 2022
49e4d90
Add files via upload
SEN316 Oct 14, 2022
3f6efa9
Update README.md
SEN316 Oct 14, 2022
762b8cd
Update README.md
SEN316 Oct 14, 2022
118f017
Update README.md
SEN316 Oct 14, 2022
6191b6e
Update README.md
SEN316 Oct 14, 2022
3a82c13
Create pic
SEN316 Oct 17, 2022
df82d55
Add files via upload
SEN316 Oct 17, 2022
c2a246b
Delete pic
SEN316 Oct 17, 2022
ba301be
Delete Cmake.png
SEN316 Oct 17, 2022
971af4b
Delete GNU Toolchain.png
SEN316 Oct 17, 2022
0cd2662
Delete Putty.png
SEN316 Oct 17, 2022
e4b037d
Delete VScode.png
SEN316 Oct 17, 2022
009fe87
Delete git1.png
SEN316 Oct 17, 2022
7712f13
Delete git2.png
SEN316 Oct 17, 2022
d1734f8
Delete git3.png
SEN316 Oct 17, 2022
d3fa110
Delete git4.png
SEN316 Oct 17, 2022
5cf2399
Delete git5.png
SEN316 Oct 17, 2022
ffee57c
Delete hello.png
SEN316 Oct 17, 2022
37033af
Delete nmake.png
SEN316 Oct 17, 2022
6743727
Delete python3.10.png
SEN316 Oct 17, 2022
ec61d15
Add files via upload
SEN316 Oct 17, 2022
bc0c16e
Update README.md
SEN316 Oct 17, 2022
f164e5b
Update README.md
SEN316 Oct 17, 2022
498490d
Update README.md
SEN316 Oct 17, 2022
2a2008f
Update README.md
SEN316 Oct 17, 2022
c05ff4f
Update README.md
SEN316 Oct 17, 2022
e4aa296
Update README.md
SEN316 Oct 17, 2022
61baa79
Add files via upload
SEN316 Oct 17, 2022
0deda4f
Update README.md
SEN316 Oct 18, 2022
f6e58e1
Create 3.5
SEN316 Oct 18, 2022
d600e02
Add files via upload
SEN316 Oct 18, 2022
d312cf2
Delete 3.5
SEN316 Oct 18, 2022
4eedd61
Add files via upload
SEN316 Oct 18, 2022
5de3dbd
Add files via upload
SEN316 Oct 18, 2022
88abe6f
Delete ws2812.c1.jpg
SEN316 Oct 18, 2022
f59d8ce
Delete ws2812.c2.jpg
SEN316 Oct 18, 2022
7f65a54
Delete ws2812.pio.h1.jpg
SEN316 Oct 18, 2022
da29da7
Delete ws2812.pio.h2.jpg
SEN316 Oct 18, 2022
baf5042
Update README.md
SEN316 Oct 18, 2022
590b64d
Update README.md
SEN316 Oct 18, 2022
389c10a
Update README.md
SEN316 Oct 18, 2022
3d775ae
Create ji
SEN316 Oct 18, 2022
3628f2b
Add files via upload
SEN316 Oct 18, 2022
eb05b84
Delete ji
SEN316 Oct 18, 2022
3b16965
Update README.md
SEN316 Oct 18, 2022
73593fb
Add files via upload
SEN316 Oct 18, 2022
02b380e
Update README.md
SEN316 Oct 18, 2022
b809ece
Add files via upload
SEN316 Oct 18, 2022
356cb55
Update README.md
SEN316 Oct 18, 2022
38fb157
Update README.md
SEN316 Oct 18, 2022
b407e70
Update README.md
SEN316 Oct 18, 2022
03bb1f7
Update README.md
SEN316 Oct 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Cmake.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GNU Toolchain.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Lab 2 Prob3/3.5.pdf
Binary file not shown.
Binary file added Lab 2 Prob3/3.6.xlsx
Binary file not shown.
Binary file added Lab 2 Prob3/3.7.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Lab 2 Prob3/part3.4 - Sheet1.pdf
Binary file not shown.
Binary file added Lab 2 Prob3/ws2812.c1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Lab 2 Prob3/ws2812.c2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Lab 2 Prob3/ws2812.pio.h1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Lab 2 Prob3/ws2812.pio.h2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Putty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
77 changes: 72 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,76 @@
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)
Name: Sen Luo
email: [email protected]
Tested on: Razer Blade 15 (15-inch, 2020), Windows 10 21H2

# Part3 TALKING LEDS

## Brief responses to the reading questions in 3.2

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

Due to the timing uncertainty of actually entering an interrupt handler, the bit-banging become impractical. Another choice is to set the processor in a carefully times loop trying to make sure the GPIO reading and writing happens on the exact cycle required, which is really hard work.

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

LEDs and push buttons.

- How do you get data into a PIO state machine?

The pull instruction takes one data item from the transmit FIFO buffer, and places it in the output shift register (OSR). Data moves from the FIFO to the OSR one word (32 bits) at a time.

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

The out instruction here takes one bit from the data we just pull-ed from the FIFO, and writes that data to some pins.

- How do you program a PIO state machine?

There are three things to consider here:
1. The state machine needs to be told which GPIO or GPIOs to output to.
2. The GPIO also needs to be told that PIO is in control of it(GPIO function select)
3. If we are using the pin for output only, we need to make sure that PIO is driving the output enable line high.

- 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, 1):
```
After you set up everything correctly, the state machine will run autonomously,then the processor will push data directly into the state machine' TX FIFO. Writing 1 will turn the LED on, and writing a 0 will turn the LED off.

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

The role of the pioasm assembler is to translating assembly code into binary. If Cmake functions want to interact with pioasm, you need take care of invoking pioasm and adding the generated header to the include path of the target TARGET for you.

## 3.3 FOLLOW THE FLOW
For this part, I tried to describe the definition of the functions and their runing sequence.
### ws2812.c
![](https://github.com/SEN316/ese5190-2022-lab2-into-the-void-star/blob/main/Lab%202%20Prob3/ws2812.c1.jpg)

![](https://github.com/SEN316/ese5190-2022-lab2-into-the-void-star/blob/main/Lab%202%20Prob3/ws2812.c2.jpg)

### ws2812.pio.h
![](https://github.com/SEN316/ese5190-2022-lab2-into-the-void-star/blob/main/Lab%202%20Prob3/ws2812.pio.h1.jpg)

![](https://github.com/SEN316/ese5190-2022-lab2-into-the-void-star/blob/main/Lab%202%20Prob3/ws2812.pio.h2.jpg)

## 3.4 COLOR BY NUMBER
For this part, I choose color 0X0000FF(BLUE).

[3.4 link](https://github.com/SEN316/ese5190-2022-lab2-into-the-void-star/blob/main/Lab%202%20Prob3/part3.4%20-%20Sheet1.pdf)
## 3.5 MODELING TIME
[3.5 link](https://github.com/SEN316/ese5190-2022-lab2-into-the-void-star/blob/main/Lab%202%20Prob3/3.5.pdf)
## 3.6 ZOOMING IN
[3.6 link](https://github.com/SEN316/ese5190-2022-lab2-into-the-void-star/blob/main/Lab%202%20Prob3/3.6.xlsx)
## 3.7 TIMING DIAGRAM
![](https://github.com/SEN316/ese5190-2022-lab2-into-the-void-star/blob/main/Lab%202%20Prob3/3.7.jpg)

## Reflection
For this lab, I chose to use "Notability" in iPad to finish handwritting part. Although I think writing is not as fast as typing, drawing forms by hand sometimes is easier than creating proper forms on computer. What's more, I am not familiar with working with spreadsheets. Sometimes, I feel it takes me a lot of time on adjust the format of the spreadsheets.

# Part4 HELLO, BLINKENLIGHT
[part4 folder](https://github.com/SEN316/ese5190-2022-lab2-into-the-void-star/tree/main/lab2%20prob4)

In this part, I modify hello_usb.c to make my LED to switch between blue and green constantly. By using PuTTY, you can find the program print "Hello, world! BLUE" when LED blue light blink and print "Hello, world! GREEN" when LED green light blink.

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.)
Binary file added VScode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added git1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added git2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added git3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added git4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added git5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added guide/Cmake.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added guide/GNU Toolchain.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added guide/Putty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added guide/VScode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added guide/git1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added guide/git2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added guide/git3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added guide/git4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added guide/git5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added guide/hello.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added guide/nmake.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added guide/python3.10.png
Binary file added hello.png
35 changes: 35 additions & 0 deletions lab2 prob4/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
cmake_minimum_required(VERSION 3.12)

# Pull in SDK (must be before project)
include(pico_sdk_import.cmake)

project(pico_examples C CXX ASM)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

if (PICO_SDK_VERSION_STRING VERSION_LESS "1.3.0")
message(FATAL_ERROR "Raspberry Pi Pico SDK version 1.3.0 (or later) required. Your version is ${PICO_SDK_VERSION_STRING}")
endif()

set(PICO_EXAMPLES_PATH ${PROJECT_SOURCE_DIR})

# Initialize the SDK
pico_sdk_init()

include(example_auto_set_url.cmake)
# Add blink example


# Add hello world example


add_compile_options(-Wall
-Wno-format # int != int32_t as far as the compiler is concerned because gcc has int32_t as long int
-Wno-unused-function # we have some for the docs that aren't called
-Wno-maybe-uninitialized
)

# Hardware-specific examples in subdirectories:

add_subdirectory(pio)

23 changes: 23 additions & 0 deletions lab2 prob4/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Contributing to Raspberry Pi Pico C/C++ Examples

## How to Report a Bug

We use GitHub to host code, track [issues](https://github.com/raspberrypi/pico-examples/issues) and feature requests, and to accept [pull requests](https://github.com/raspberrypi/pico-examples/pulls). If you find think you have found a bug, please report it by [opening a new issue](https://github.com/raspberrypi/pico-examples/issues/new). Please include as much detail as possible, and ideally some code to reproduce the problem.

## How to Contribute Code

In order to contribute new or updated code, you must first create a GitHub account and fork the original repository to your own account. You can make changes, save them in your repository, then [make a pull request](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork) against this repository. The pull request will appear [in the repository](https://github.com/raspberrypi/pico-examples/pulls) where it can be assessed by the maintainers, and if appropriate, merged with the official repository.

**NOTE:** Development takes place on the `develop` branch in this repository. Please open your https://github.com/raspberrypi/pico-examples/pulls[pull request] (PR) against the [`develop`](https://github.com/raspberrypi/pico-examples/tree/develop) branch, pull requests against the `master` branch will automatically CI fail checks and will not be accepted. You will be asked to rebase your PR against `develop` and if you do not do so, your PR will be closed.

### Code Style

If you are contributing new or updated code please match the existing code style, particularly:

* Use 4 spaces for indentation rather than tabs.
* Braces are required for everything except single line `if` statements.
* Opening braces should not be placed on a new line.

### Licensing

Code in this repository is lisensed under the [BSD-3 License](LICENSE.TXT). By contributing content to this repository you are agreeing to place your contributions under this licence.
21 changes: 21 additions & 0 deletions lab2 prob4/LICENSE.TXT
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Copyright 2020 (c) 2020 Raspberry Pi (Trading) Ltd.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Loading