Starting with this project - makoteo/weeklychores GitHub Wiki

Test code - Blinky

Just to be sure everything is working oki, before you try the real code, run Blinky. Here is how:

  1. Create New Standalone Project
  2. Select Device (ATSAMD21G18A)
  3. Select J-Link->SN: xxxxxxxx
  4. Select Compiler XC32->XC32 (vx.xx)
  5. Name Project: Test
  6. Finish
  7. Right click on Source files in Project Panel -> New -> XC32_newfile.c: Neame new file main
  8. Copy and paste following code into main.c
#define GROUP1DIR *(unsigned int *)(0x41004480)
#define GROUP1OUT *(unsigned int *)(0x41004490)
#define LEDPIN 0x100

void main (void){
    GROUP1DIR = GROUP1DIR|LEDPIN; //SET LED PIN AS OUTPUT
    GROUP1OUT = GROUP1OUT|LEDPIN; //SET LED HIGH
    
    unsigned int i;
    while(1){
        for (i=0;i<20000;i++){
            GROUP1OUT = GROUP1OUT&(~LEDPIN);
        }    
        for (i=0;i<20000;i++){
            GROUP1OUT = GROUP1OUT|LEDPIN; //SET LED HIGH
        }
    }
}

And then: Debug -> Debug Main Project. The orange LED should start blinking.

Using project from github

To download the project from github, here is how you can do it:

  1. git clone https://github.com/makoteo/weeklychores.git
  2. Open in MPLAB
  3. Build

Creating as a new project

In case you have any problems to run the project from github directly, you will need create an empty project and then copy the files manually. This is approximately how you can do it:

  1. Create New Standalone Project
  2. Select Device (ATSAMD21G18A)
  3. Select J-Link->SN: xxxxxxxx
  4. Select Compiler XC32->XC32 (vx.xx)
  5. Name Project (WeeklyChores)
  6. Finish
  7. Right click on the Source files and add all the files
  8. Important: Do not forget to set heap (right click on project, properties, xc32-ld, Heap size) to 8000

Installing all the necessary software

  1. JTAG J-link software https://www.segger.com/downloads/jlink/JLink_Windows.exe
  2. Compiler http://ww1.microchip.com/downloads/en/DeviceDoc/xc32-v2.40-full-install-windows-installer.exe (When asked, check: Add Compiled PATH ...)
  3. MPLAB IDE http://ww1.microchip.com/downloads/en/DeviceDoc/MPLABX-v5.35-windows-installer.exe

Hardware Used

  1. Arduino MKR ZERO https://store.arduino.cc/arduino-mkr-zero-i2s-bus-sd-for-sound-music-digital-audio-data
  2. J-link EDU https://uk.farnell.com/segger/8-08-90-j-link-edu/jtag-emulator-j-link-edu-usb/dp/2098545
  3. 2.7inch e-paper https://www.waveshare.com/2.7inch-e-Paper.htm

Connection

Arduino MKR ZERO connection to E-paper

Arduino MKR ZERO E-paper
VCC VCC (red)
GND GND (black)
MOSI (8) DIN (blue)
SCK (9) CLK (yellow)
7 CS (orange)
6 DC (green)
4 RST (white)
5 BUSY (purple)

Arduino MKR ZERO connection to J-link

Arduino MKR ZERO J-link JTAG
J8 (1) VTref (1)
J8 (2) SWDIO (7)
J8 (3) RESET (15)
J8 (4) SWCLK (9)
J8 (5) GND (12)
J8 (6) Not connected

Connections