Skip to content
Snippets Groups Projects
Commit 48f2a2ea authored by Dan Stone's avatar Dan Stone
Browse files

baremetal update

parent d66cfe3e
No related branches found
No related tags found
No related merge requests found
Pipeline #375735 passed
# 5. Embedded Programming
This week we are starting off on the embedded programing topics.
This week we are starting off on the embedded programming topics.
Our group assignment was the compare different architecture of micro controller. It is clear to me that
choosing the right micro controller is key given to a successful project. The different features, cost, speed
......@@ -9,28 +9,28 @@ would work best is worth it;
**Accomplishments:**
I have had some experience working with Arduino and 412 in the fab academy prep session we have had and so
I revisited the 412 for bare metal programing but focused mainly on the RP2040 and the Arduino.
I revisited the 412 for bare metal programming but focused mainly on the RP2040 and the Arduino.
1. Reviewed the Data sheet for RP2040 and ESP32-s2
2. Made a More Code transmitter using the RP2040 and C
3. Used Micro python for the first time to make the RP2040 blink
2. Made a Morse Code "transmitter" using the RP2040 and C
3. Used Micro python for the first time to make the RP2040 blink a LED
4. Built a first cut at final project circuitry using the Arduino and C
5. Tried out ChatGPT for some of the code development - got a basic structure in place but had to
do clean up/changes
6. Reviewed the 412 work we did in Prep week with input (Button Photo resistor) and outputs (LEDs)
7. Wrote my first bare metal program making the 412 blink 2 LEDs
7. Wrote my first bare metal program for the ATTiny 412 to blink an LED
## Reading the data sheets RP2040 / ESP32-S2
I reviewed through the data sheetS FOR [RP2040](https://academy.cba.mit.edu/classes/embedded_programming/RP2040/RP2040.pdf) and the [ESP32-s2](../files/Week5/Datasheets/esp32-s2_datasheet_en.pdf). They are both ery dense and after reading the intro and skimming some of the other areas
looking for answers to our group assigment some things start to look more familiar. Especially given the bare metal
programing that reviewed in our Lab last week.
looking for answers to our group assignment some things start to look more familiar. Especially given the bare metal
programming that reviewed in our Lab last week.
## R2040 in C
I wanted to start with programing the R2040 to blink using C in the Arduino IDE and MicroPython
I wanted to start with programming the R2040 to blink using C in the Arduino IDE and MicroPython
I got a set of parts and given the availability in our lab will use the Raspberry Pico for this excersize.
......@@ -209,7 +209,7 @@ I do not know python so I first took a basic tutorial
I used the following direction to get Micropython loaded [here](https://www.raspberrypi.com/documentation/microcontrollers/micropython.html) and Thonny installed as an IDE [here](https://thonny.org/)
No I ran through a basic python tutorial and it was straight forwad.
No I ran through a basic python tutorial and it was straight forward.
Using the following code:
......@@ -599,7 +599,64 @@ I looked up the pinout map for the ATTiny412
Now it was time to start the coding
Based on the map and the ATTiny
Based on the map and the ATTiny I wanted to take the Blink code and start replacing some of the code
turning PIN2 to out put and then turning it one and off
Here is the starting code:
```c
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(1, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
```
To start off I replaced
pinMode(2, OUTPUT); with DDRB = 1; based on many of the example I have seen however it seemed the DDRB
was not recognized....a LOT of googleing later I found out that for 412 the code is differnt then for
the Ardunio and I need to use PORT.DIR;
So I set up
PORT.DIR = 1; and....no blinking.
Reviewing the lecture and discuss with a class mate I was reminded that this is index 0 so PA1 is actualy the second
slot and so I need to set it to 2 to turn on, not 1.
PORT.DIR = 2;
worked!
Now to replace digitalWrite(1, HIGH);
For the 412 I needed to us PORTA.OUT = 2; which again was differnt then the other examples and so here
is the final code I used:
```c
void setup() {
// initialize digital pin LED_BUILTIN as an output.
PORTA.DIR = 1;
}
// the loop function runs over and over again forever
void loop() {
PORTA.OUT = 2; // turn the LED on (HIGH is the voltage level)
delay(200); // wait for a second
PORTA.OUT = 0; // turn the LED on (HIGH is the voltage level)
delay(200); // wait for a second
}
```
<iframe width="560" height="315" src=../../images/ImagW4/Bare412.mp4 frameborder="0" allowfullscreen></iframe>
**Here are the files from this week work**
......@@ -608,4 +665,6 @@ Based on the map and the ATTiny
[Micro Python Blink](../files/Week5/MorseCode/MicropythonBlink.py)
[412 Bare metal Blink](../files/Week5/MorseCode/BlinkBaremetal/BlinkBaremetal.ino)
[Vegetable Washing Machine V1.0 Code](../files/Week5/VMS1/VMS1.ino)
\ No newline at end of file
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
PORTA.DIR = 1;
}
// the loop function runs over and over again forever
void loop() {
PORTA.OUT = 2; // turn the LED on (HIGH is the voltage level)
delay(200); // wait for a second
PORTA.OUT = 0; // turn the LED on (HIGH is the voltage level)
delay(200); // wait for a second
}
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment