EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / “Hello World!” with ATxmega256A3

“Hello World!” with ATxmega256A3

|

Microcontroller › AVR › “Hello World!” with ATxmega256A3

  • This topic has 0 replies, 1 voice, and was last updated 9 years, 9 months ago by Gabriella.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • October 8, 2015 at 12:30 pm #4039
    Gabriella
    Participant

    Hi all,

    I am using two radio extender boards from a REB233SMAD-EK kit and an AVRISP mkII programmer in Atmel Studio 6.2. Though the two boards seem to be recognizing each other (LED diodes blink to show successful wireless communication), 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, meaning 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.":

    /*
    * 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 am unsure of how to get the "Hello World!" message communicated between my two boards using the AVRISP mkII. Would I need a debugger? Is there a way I can program without it?

    Any help would be very appreciated!!

  • Author
    Posts
Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Does US electric code allow branching ? July 19, 2025
  • Faulty heat air gun (dc motor) - problem to locate fault due to Intermittent fault July 19, 2025
  • Fun with AI and swordfish basic July 19, 2025
  • Sump pit water alarm - Kicad 9 July 19, 2025
  • turbo jet fan - feedback appreciated. July 19, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise