poroko
New Member
Hi all,
I am using two REB233SMAD-EK radio extender boards and an AVRISP mkii programmer in Atmel Studio 6.2. Though the two boards seem to be recognizing each other (apparent in terminal), I cannot find a way in which to get them to send/receive a simple message (such as "Hello World!"). I've been told that the AVRISP mkii is simply a programmer, so in other words, it doesn't debug. Because of this, whenever I try to debug the following code, Atmel Studio consistently displays an error message stating "Failed to launch program. Error: Failed to start programming session before chip erase with eeprom preserve:Failed to enter programming mode. Error status received from tool: Result received is 0x03.":
I'm unsure of how to get this message communicated between my two boards using the AVRISP mkii. Would I need a debugger? Is there a way I can program without it? I am a neophyte when it comes to programming, so any help would be very appreciated!!
I am using two REB233SMAD-EK radio extender boards and an AVRISP mkii programmer in Atmel Studio 6.2. Though the two boards seem to be recognizing each other (apparent in terminal), I cannot find a way in which to get them to send/receive a simple message (such as "Hello World!"). I've been told that the AVRISP mkii is simply a programmer, so in other words, it doesn't debug. Because of this, whenever I try to debug the following code, Atmel Studio consistently displays an error message stating "Failed to launch program. Error: Failed to start programming session before chip erase with eeprom preserve:Failed to enter programming mode. Error status received from tool: Result received is 0x03.":
Code:
/*
* Hello_World.c
*
* Created: 8/21/2015 2:23:17 PM
* Author: Hugo
*/
#include <stdio.h>
#include <avr/io.h>
static int uart_putchar(char c, FILE *stream);
static void uart_init (void);
static FILE mystdout = FDEV_SETUP_STREAM (uart_putchar, NULL, _FDEV_SETUP_WRITE);
int main (void)
{
uart_init();
stdout = &mystdout;
while (1)
printf("Hello, world!\n");
}
static int uart_putchar (char c, FILE *stream)
{
if (c == '\n')
uart_putchar('\r', stream);
// Wait for the transmit buffer to be empty
while ( !( USARTC0.STATUS & USART_DREIF_bm) );
// Put our character into the transmit buffer
USARTC0.DATA = c;
return 0;
}
// Init USART. Transmit only (we're not receiving anything)
// We use USARTC0, transmit pin on PC3.
// Want 9600 baud. Have a 2 MHz clock. BSCALE = 0
// BSEL = ( 2000000 / (2^0 * 16*9600)) -1 = 12
// Fbaud = 2000000 / (2^0 * 16 * (12+1)) = 9615 bits/sec
static void uart_init (void)
{
// Set the TxD pin high - set PORTC DIR register bit 3 to 1
PORTC.OUTSET = PIN3_bm;
// Set the TxD pin as an output - set PORTC OUT register bit 3 to 1
PORTC.DIRSET = PIN3_bm;
// Set baud rate & frame format
USARTC0.BAUDCTRLB = 0; // BSCALE = 0 as well
USARTC0.BAUDCTRLA = 12;
// Set mode of operation
USARTC0.CTRLA = 0; // no interrupts please
USARTC0.CTRLC = 0x03; // async, no parity, 8 bit data, 1 stop bit
// Enable transmitter only
USARTC0.CTRLB = USART_TXEN_bm;
}
I'm unsure of how to get this message communicated between my two boards using the AVRISP mkii. Would I need a debugger? Is there a way I can program without it? I am a neophyte when it comes to programming, so any help would be very appreciated!!