Society of Robots - Robot Forum

Software => Software => Topic started by: Silver_79 on July 29, 2012, 03:24:40 PM

Title: AXON & Hello World / LED Test
Post by: Silver_79 on July 29, 2012, 03:24:40 PM
Hi,

I have been trying to get my Axon to do an very basic LED blink as I am learning to program I figured this would be a good start. I have 5.52 V applied to the Axons Bat pin for power and An AVR ISP MKK II set up on its six pin header to load up the code. The LED is placed across Pin 1 on PORT A from ground to the I/O pin ( ie skipping the middle + Unregulated Battery pin. The Code I am tinkering with is :



Code: [Select]
#define F_CPU 16000000    // AVR clock frequency in Hz, used by util/delay.h
#include <avr/io.h>
#include <util/delay.h>

int main() {

   DDRA = _BV(PA6);
 
  while (1) {
PORT_ON(PORTA,1);
_delay_ms(100);         // delay 100 ms
PORT_OFF(PORTA,1); // drive A1 low
_delay_ms(900);         // delay 900 ms

}
}


The Errors I get are thus:


Warning   1   implicit declaration of function 'PORT_ON' [-Wimplicit-function-declaration]   C:\Users\Donald\Documents\Atmel Studio\BlinK_LED_3\BlinK_LED_3\BlinK_LED_3.c   10   4   BlinK_LED_3
Warning   2   implicit declaration of function 'PORT_OFF' [-Wimplicit-function-declaration]   C:\Users\Donald\Documents\Atmel Studio\BlinK_LED_3\BlinK_LED_3\BlinK_LED_3.c   12   4   BlinK_LED_3
Error   3   undefined reference to `PORT_ON'   C:\Users\Donald\Documents\Atmel Studio\BlinK_LED_3\BlinK_LED_3\Debug/.././BlinK_LED_3.c   10   1   BlinK_LED_3
Error   4   undefined reference to `PORT_OFF'   C:\Users\Donald\Documents\Atmel Studio\BlinK_LED_3\BlinK_LED_3\Debug/.././BlinK_LED_3.c   12   1   BlinK_LED_3


**IDE is AVR studio 6.018

Code compiles fine without the PORT_ON and PORT_OFF in it but nothing on the LED. Any help would be great.


Thanks,
Don
Title: Re: AXON & Hello World / LED Test
Post by: newInRobotics on July 30, 2012, 03:28:31 AM
You don't have libraries included that defines PORT_ON and PORT_OFF :)

Try this code:
Code: [Select]
#define F_CPU 16000000    // AVR clock frequency in Hz, used by util/delay.h
#include <avr/io.h>
#include <util/delay.h>

int main()
{
DDRA |= 1 << DDA1;

for(;;)
{
PORTA |= 1 << 1; // drive A1 high
_delay_ms(100); // delay 100 ms
PORTA &= ~(1 << 1); // drive A1 low
_delay_ms(900); // delay 900 ms
}
}
Title: Re: AXON & Hello World / LED Test
Post by: Silver_79 on July 30, 2012, 05:18:22 AM
cool will give it a shot after work today. I knew it was going to be something stupid like that lol :P

Thanks
Don
Title: Re: AXON & Hello World / LED Test
Post by: Silver_79 on September 09, 2012, 12:18:14 PM
Thanks, worked