Go to the webpage www.mplab-xpresside.microchip.com. You may have to create an account and password.
This is blank. No project is active. Click on the File menu and select New Project.
Select Microchip Embedded and Standalone Project
Type in Atmega328p to Select Device
Name the project count
Click Finish and we are in the IDE. No source code files have been created.
Right click on the Project folder Count and select New File to add to the project.
Create a new C Main File
An XC8 Compiler will be generating our code. This compiler is at the MicroChip website and not installed on your computer.
Any name will work. The default is for our new file to be called newmain.c.
The default code in this newmain.c file will compile correctly but it will not perform any functions. Replace the default code with:
// PORTB is an 8bit number at address 0x24
#define F_CPU 16000000
#include <avr/io.h>
#include <util/delay.h>
int main(void){ DDRB = 0xFF; // turn PORTB on
while(1){PORTB++; // increment PORTB
_delay_ms(100); // delay
}}
This code will have the Arduino count in binary numbers on PORTB. It will also turn the built in LED on the board on and off about once a second.
Go to the Run menu and click on either Build Project or Clean and Build Project. Not all of the keyboard shortcuts are implemented and may be commands to your browser.
We are looking for the message Build Successful at the bottom of the screen. You may receive a message that a new file has been generated on your computer called count.hex. Look in your Download folder.
Make and Program Device menu will ensure the hex file is generated. If you see extra files like count(1).hex they are the same thing and will upload to a board and run. Delete any extra .hex files as you use the IDE.
Currently, the XpressIDE supports programming and debugging with only a few specific tools such as the PICkit programmers. It does have a simulator for the Atmega328p MCU and you should explore debugging with it.
Assuming your computer already has the avrdude program. Open a terminal in the same directory as count.hex and use this command for the Uno.
$ avrdude -p atmega328p -c arduino -P /dev/ttyACM0 -U flash:w:count.hex:i
On windows use the same command but change /dev/ttyACM0 to the windows com port for the Arduino board.
> avrdude -p atmega328p -c arduino -P com4 -U flash:w:count.hex:i
At this point you should have the built in LED on the Arduino board blinking about once a second.
Comments