To build AVR firmware AVR studio 4 is used. It can be downloaded directly from ATMEL corporation web site.
Run AVR Studio. Select New Project
menu item from AVR Studio Project menu. In the opened dialog
define Project type as Atmel AVR Assembler,
type DefendLine4 in Project name field and
select source code location which is in
Click Finish button. The project tree should be created and the
only initial file
DefendLine4.asm should be displayed. By right mouse
click on project's Source Files item and choosing
Add Files to Project add the rest
Before building the project must be configured to comply with target
AVR microprocessor, hardware accessories and desirable user settings. There are a few
things to be defined in
DefendLine4.asm, please see the code fragment
Example 4.1. DefendLine4.asm Settings
.include "m32def.inc" ;.include "m16def.inc" ;#define _EXT_DISPLAY_ ;#define _TEST_
First line defines which type of AVR processor should the code be compiled for.
.include "m32def.inc" defines ATMega32. By uncommenting
#define _EXT_DISPLAY_ external LED matrix display support is enabled.
This option is not used in current hardware configuration. And finally, by definition
#define _TEST_ internal tests will be enabled, this feature helps
debugging code and do some validation in AVR simulator.
Current AVR source code version is compatible with ATMega32. Nevertheless, the small code footprint potentially fits in AVR16 but some efforts must be made to adapt the code for the latter one while keeping compatibility with ATMega32.
There is one and only one user configuration which must be defined in
Config.asm, please see the code fragment below.
Example 4.2. Config.asm Settings
#define _CONF1_ #if defined(_CONF1_) device_id: .db "0123", 0, 0 DA_def: .db "0B912143658709F1", 0, 0;12345678901 - 1st destination phone number DA_def2: .db "0B912143658709F1", 0, 0;12345678901 - 2nd destination phone number ;--- Textual representation of detector states --- det_infrared: .db "IR detector ", 0, 0 det_balcony_door: .db "Balcony door ", 0 det_verandah_door: .db "Door of verandah ", 0 det_main_gate: .db "Main gate", 0 #endif .EQU REPORT_HOUR = 0x0;
In our case this user configuration called
_CONF1_. Let's enumerate
all the configuration parameters. The first one,
device_id defines unique
4-character microcontroller unit identifier. It allows to distinguish units which send
data to the same server. The second and the third parameters
DA_def2 define mobile phone numbers which will be used as SMS notifications
recipients when the unit works in simple mode. Parameters
det_main_gate give more meaningful names to sensors, they make it easier
to comprehend unit's reports and notifications.
REPORT_HOUR defines report hour - time, when daily report
will be sent.
0x0 means 0:00 or midnight.
The project is ready to be built. Select Build
menu item from AVR Studio Build menu.
file will be created. Flash it to the target microprocessor by means of any
AVR ISP programmer.