Skip to content

Embedded programming

2022

For this week I used the SAMD11C board, with led and button, which I made in Electronics Design week.

Programming is something I’ll have to focus more in the future. I am interested in understanding more of it, but with the time I have, I focused on completing this task to a minimal degree.

I read part of the datasheet for the SAMD11C in previous electronics weeks, as this is the microcontroller I’ve been working with.

For this week, the main concern was how to address the pins I needed in Arduino. I also referred to Quentin Bolsee’s Arduino Fab Sam Core documentation on this microcontroller, which right at the top has a diagram on the available pins:

====================================== ATsamD11C14A =====================================
Other  COM   PWM  Analog  INT  Arduino*           Arduino*  INT  Analog  PWM   COM  Other
=========================================================================================
                                 1-------------------
 SCK*/RX2  TCC01    *     *    5 | A5             A4 | 4    *    *  TCC00 MOSI*/TX2  REF
   MOSI*   TCC02          *    8 | A8 (XIN)       A2 | 2    *    *                   DAC
   SCK*    TCC03          *    9 | A9 (XOUT)     Vdd |
 SDA/MISO*  TC10    *    NMI  14 | A14           Gnd |
  SCL/SS*   TC11    *     *   15 | A15           A25 | 25                    USB/DP
BOOT                           28 | A28/RST       A24 | 24                    USB/DM
SWDCLK  TX1/MISO*              30 | A30           A31 | 31   *            RX1/SS*   SWDIO
                                  -------------------

I then looked for a sketch that used a button and an LED, and found this one on Arduino Project Hub, to Which I changed the pin numbers to the ones I was using on my board, in Arduino IDE.

const int BUTTON = 8;
const int LED = 14;
int BUTTONstate = 0;

void setup()
{
 pinMode(BUTTON, INPUT);
 pinMode(LED, OUTPUT);
}

void loop()
{
 BUTTONstate = digitalRead(BUTTON);
 if (BUTTONstate == HIGH)
 {
   digitalWrite(LED, HIGH);
 }
 else{
   digitalWrite(LED, LOW);
 }
}

If I want to change what the button does, I swap HIGH and LOW on the digitalWrite in the if statement and upload again.

Files

Arduino sketch for turning the led on or off with the button

Checklist

Group assignment

  • Compare the performance and development workflows for different microcontroller families
  • Document your work (in a group or individually)

Individual assignment

  • Read the datasheet for the microcontroller you are programming
  • Program the board you have made to do something, with as many different programming languages and programming environments as possible.

Learning outcomes

  • Identify relevant information in a microcontroller datasheet.
  • Implement programming protocols.

Have you?

  • Linked to the group assignment page
  • Documented what you learned from reading a microcontroller datasheet.
  • Programmed your board
  • Described the programming process/es you used
  • Included your source code
  • Included a short ‘hero video’ of your board

Last update: March 18, 2024