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:
- Create New Standalone Project
- Select Device (ATSAMD21G18A)
- Select J-Link->SN: xxxxxxxx
- Select Compiler XC32->XC32 (vx.xx)
- Name Project: Test
- Finish
- Right click on Source files in Project Panel -> New -> XC32_newfile.c: Neame new file main
- 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:
git clone https://github.com/makoteo/weeklychores.git
- Open in MPLAB
- 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:
- Create New Standalone Project
- Select Device (ATSAMD21G18A)
- Select J-Link->SN: xxxxxxxx
- Select Compiler XC32->XC32 (vx.xx)
- Name Project (WeeklyChores)
- Finish
- Right click on the Source files and add all the files
- Important: Do not forget to set heap (right click on project, properties, xc32-ld, Heap size) to 8000
Installing all the necessary software
- JTAG J-link software https://www.segger.com/downloads/jlink/JLink_Windows.exe
- Compiler http://ww1.microchip.com/downloads/en/DeviceDoc/xc32-v2.40-full-install-windows-installer.exe (When asked, check: Add Compiled PATH ...)
- MPLAB IDE http://ww1.microchip.com/downloads/en/DeviceDoc/MPLABX-v5.35-windows-installer.exe
Hardware Used
- Arduino MKR ZERO https://store.arduino.cc/arduino-mkr-zero-i2s-bus-sd-for-sound-music-digital-audio-data
- J-link EDU https://uk.farnell.com/segger/8-08-90-j-link-edu/jtag-emulator-j-link-edu-usb/dp/2098545
- 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 |