Skip to content
Snippets Groups Projects
Commit c63e4de6 authored by Sam Calisch's avatar Sam Calisch
Browse files

Merge branch 'jake' into 'master'

fix typo, mixed refs

See merge request !2
parents 9c5a36af 4b22131f
No related branches found
No related tags found
1 merge request!2fix typo, mixed refs
Pipeline #
...@@ -16,8 +16,8 @@ pre code { ...@@ -16,8 +16,8 @@ pre code {
<h1>M0 - ATSAMD21</h1> <h1>M0 - ATSAMD21</h1>
<figure> <figure>
<img src='m0-feather.jpg'> <img src='m0-feather.jpg' height=50%>
<figcaption>Ring oscillator with M0.</figcaption> <figcaption>Ring oscillator with M0 Feather.</figcaption>
</figure> </figure>
<p>This ring oscillator runs on the 'M0' ATSAMD21, which is a fairly popular microcontroller with an Arm Cortex M0 at it's heart. It has native USB functionality, and is supported with an Adafruit bootloader, making writing and running code fairly straightforward. I used Adafruit's Feather dev board for this test.</p> <p>This ring oscillator runs on the 'M0' ATSAMD21, which is a fairly popular microcontroller with an Arm Cortex M0 at it's heart. It has native USB functionality, and is supported with an Adafruit bootloader, making writing and running code fairly straightforward. I used Adafruit's Feather dev board for this test.</p>
...@@ -40,36 +40,32 @@ pre code { ...@@ -40,36 +40,32 @@ pre code {
#define PIN_11_PORT 0 #define PIN_11_PORT 0
#define PIN_11_PIN 16 #define PIN_11_PIN 16
#define LED_OUTSET PORT->Group[PIN_LED_PORT].OUTSET.reg uint32_t ulPin = 11;
#define LED_OUTCLR PORT->Group[PIN_LED_PORT].OUTCLR.reg
#define RING_PORT_OUTSET PORT->Group[PIN_10_PORT].OUTSET.reg
#define RING_PORT_OUTCLR PORT->Group[PIN_10_PORT].OUTCLR.reg
#define RING_PORT_OUT_MASK (1UL << PIN_10_PIN)
#define RING_PORT_IN PORT->Group[PIN_11_PORT].IN.reg
#define RING_PORT_IN_MASK (1UL << PIN_11_PIN)
void setup() { void setup() {
// set a pin to in // set a pin to in / out ... starting
PORT->Group[PIN_LED_PORT].PINCFG[PIN_LED_PIN].reg = (uint8_t)(PORT_PINCFG_INEN); PORT->Group[g_APinDescription[ulPin].ulPort].PINCFG[g_APinDescription[ulPin].ulPin].reg = (uint8_t)(PORT_PINCFG_INEN) ;
// setting same pin to out (arduino configures an output as both, so it can read its own state. handy PORT->Group[g_APinDescription[ulPin].ulPort].DIRSET.reg = (uint32_t)(1 << g_APinDescription[ulPin].ulPin) ;
PORT->Group[PIN_LED_PORT].DIRSET.reg = (uint32_t)(1 << PIN_LED_PIN);
// set 10 to output //pinMode(10, OUTPUT);
PORT->Group[PIN_10_PORT].DIRSET.reg = (uint32_t)(1 << PIN_10_PIN); //pinMode(11, INPUT);
// set 11 to input
PORT->Group[PIN_11_PORT].PINCFG[PIN_11_PIN].reg = (uint8_t)(PORT_PINCFG_INEN);
// do loop
while (1) { // no loop just c
RING_PORT_IN & RING_PORT_IN_MASK ? RING_PORT_OUTCLR = RING_PORT_OUT_MASK : RING_PORT_OUTSET = RING_PORT_OUT_MASK;
}
} }
void loop() { void loop() {
EPortType port = g_APinDescription[ulPin].ulPort;
uint32_t pin = g_APinDescription[ulPin].ulPin;
uint32_t pinMask = (1ul << pin);
Serial.print("11, port: ");
Serial.print(port);
Serial.print(" pin: ");
Serial.print(pin);
Serial.println("");
PORT->Group[port].OUTSET.reg = pinMask;
delay(100);
PORT->Group[port].OUTCLR.reg = pinMask;
delay(100);
} }
</code> </code>
</pre> </pre>
...@@ -77,18 +73,12 @@ void loop() { ...@@ -77,18 +73,12 @@ void loop() {
<p>This enabled me to write the code that I ran during the test, where the M0 clocked at 1.45MHz. Scope traces and code below.</p> <p>This enabled me to write the code that I ran during the test, where the M0 clocked at 1.45MHz. Scope traces and code below.</p>
<figure> <figure>
<img src="m0-scope.jpg" height=25%> <img src="m0-scope.jpg" height=50%>
<figcaption>Adafruit Feather dev board used in this test.</figcaption> <figcaption>Adafruit Feather dev board used in this test.</figcaption>
</figure> </figure>
<pre> <pre>
<code> <code>
/*
I found most of these definitions in the arduino cores in
AppData/Local/Arduino15/packages/adafruit/hardware/samd/1.0.19/cores/arduino/wiring_digital.c & wiring_digital.h
also samd/1.0.19/variants/variant.h and variant.cpp and pins_arduino.h
*/
#define PIN_10_PORT 0 #define PIN_10_PORT 0
#define PIN_10_PIN 18 #define PIN_10_PIN 18
...@@ -125,7 +115,7 @@ void loop() { ...@@ -125,7 +115,7 @@ void loop() {
<p>With the Arduino digitalWrite and digitalRead calls, the ring is ~162khz</p> <p>With the Arduino digitalWrite and digitalRead calls, the ring is ~162khz</p>
<figure> <figure>
<img src='m0-scope-arduino.jpg'> <img src='m0-scope-arduino.jpg' height=50%>
<figcaption>Ring oscillator with M0 using Arduino library calls.</figcaption> <figcaption>Ring oscillator with M0 using Arduino library calls.</figcaption>
</figure> </figure>
......
/* /*
I found most of these definitions in the arduino cores in I found most of these definitions in the arduino cores in
AppData/Local/Arduino15/packages/adafruit/hardware/samd/1.0.19/cores/arduino/wiring_digital.c & wiring_digital.h AppData/Local/Arduino15/packages/adafruit/hardware/samd/1.0.19/cores/arduino/wiring_digital.c & wiring_digital.h
also samd/1.0.19/variants/variant.h and variant.cpp and pins_arduino.h
*/ */
#define PIN_LED_PORT 0
#define PIN_LED_PIN 17
#define PIN_10_PORT 0 #define PIN_10_PORT 0
#define PIN_10_PIN 18 #define PIN_10_PIN 18
#define PIN_11_PORT 0 #define PIN_11_PORT 0
#define PIN_11_PIN 16 #define PIN_11_PIN 16
uint32_t ulPin = 11; #define RING_PORT_OUTSET PORT->Group[PIN_10_PORT].OUTSET.reg
#define RING_PORT_OUTCLR PORT->Group[PIN_10_PORT].OUTCLR.reg
#define RING_PORT_OUT_MASK (1UL << PIN_10_PIN)
#define RING_PORT_IN PORT->Group[PIN_11_PORT].IN.reg
#define RING_PORT_IN_MASK (1UL << PIN_11_PIN)
void setup() { void setup() {
// set a pin to in / out ... starting // set 10 to output
PORT->Group[g_APinDescription[ulPin].ulPort].PINCFG[g_APinDescription[ulPin].ulPin].reg = (uint8_t)(PORT_PINCFG_INEN) ; PORT->Group[PIN_10_PORT].DIRSET.reg = (uint32_t)(1 << PIN_10_PIN);
PORT->Group[g_APinDescription[ulPin].ulPort].DIRSET.reg = (uint32_t)(1 << g_APinDescription[ulPin].ulPin) ;
//pinMode(10, OUTPUT); // set 11 to input
//pinMode(11, INPUT); PORT->Group[PIN_11_PORT].PINCFG[PIN_11_PIN].reg = (uint8_t)(PORT_PINCFG_INEN);
// do loop
while (1) { // no loop just c
RING_PORT_IN & RING_PORT_IN_MASK ? RING_PORT_OUTCLR = RING_PORT_OUT_MASK : RING_PORT_OUTSET = RING_PORT_OUT_MASK;
}
} }
void loop() { void loop() {
EPortType port = g_APinDescription[ulPin].ulPort;
uint32_t pin = g_APinDescription[ulPin].ulPin;
uint32_t pinMask = (1ul << pin);
Serial.print("11, port: ");
Serial.print(port);
Serial.print(" pin: ");
Serial.print(pin);
Serial.println("");
PORT->Group[port].OUTSET.reg = pinMask;
delay(100);
PORT->Group[port].OUTCLR.reg = pinMask;
delay(100);
} }
/* /*
I found most of these definitions in the arduino cores in I found most of these definitions in the arduino cores in
AppData/Local/Arduino15/packages/adafruit/hardware/samd/1.0.19/cores/arduino/wiring_digital.c & wiring_digital.h AppData/Local/Arduino15/packages/adafruit/hardware/samd/1.0.19/cores/arduino/wiring_digital.c & wiring_digital.h
also samd/1.0.19/variants/variant.h and variant.cpp and pins_arduino.h
*/ */
#define PIN_LED_PORT 0
#define PIN_LED_PIN 17
#define PIN_10_PORT 0 #define PIN_10_PORT 0
#define PIN_10_PIN 18 #define PIN_10_PIN 18
#define PIN_11_PORT 0 #define PIN_11_PORT 0
#define PIN_11_PIN 16 #define PIN_11_PIN 16
#define RING_PORT_OUTSET PORT->Group[PIN_10_PORT].OUTSET.reg uint32_t ulPin = 11;
#define RING_PORT_OUTCLR PORT->Group[PIN_10_PORT].OUTCLR.reg
#define RING_PORT_OUT_MASK (1UL << PIN_10_PIN)
#define RING_PORT_IN PORT->Group[PIN_11_PORT].IN.reg
#define RING_PORT_IN_MASK (1UL << PIN_11_PIN)
void setup() { void setup() {
// set 10 to output // set a pin to in / out ... starting
PORT->Group[PIN_10_PORT].DIRSET.reg = (uint32_t)(1 << PIN_10_PIN); PORT->Group[g_APinDescription[ulPin].ulPort].PINCFG[g_APinDescription[ulPin].ulPin].reg = (uint8_t)(PORT_PINCFG_INEN) ;
PORT->Group[g_APinDescription[ulPin].ulPort].DIRSET.reg = (uint32_t)(1 << g_APinDescription[ulPin].ulPin) ;
// set 11 to input //pinMode(10, OUTPUT);
PORT->Group[PIN_11_PORT].PINCFG[PIN_11_PIN].reg = (uint8_t)(PORT_PINCFG_INEN); //pinMode(11, INPUT);
// do loop
while (1) { // no loop just c
RING_PORT_IN & RING_PORT_IN_MASK ? RING_PORT_OUTCLR = RING_PORT_OUT_MASK : RING_PORT_OUTSET = RING_PORT_OUT_MASK;
}
} }
void loop() { void loop() {
EPortType port = g_APinDescription[ulPin].ulPort;
uint32_t pin = g_APinDescription[ulPin].ulPin;
uint32_t pinMask = (1ul << pin);
Serial.print("11, port: ");
Serial.print(port);
Serial.print(" pin: ");
Serial.print(pin);
Serial.println("");
PORT->Group[port].OUTSET.reg = pinMask;
delay(100);
PORT->Group[port].OUTCLR.reg = pinMask;
delay(100);
} }
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