Serial dialog?

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quick question: where's the dialog in AVRStudio 4 for serial communications, where you can simulate data in and out of the serial port?

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

abcminiuser wrote:
Quick question: where's the dialog in AVRStudio 4 for serial communications, where you can simulate data in and out of the serial port

Hi.
Studio 4 has no such a feature at all.
Try to connect Hapsim.

Best regards Jurek S.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm sure it was in AVR Studio 3.x, why'd they remove it?

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

abcminiuser wrote:
I'm sure it was in AVR Studio 3.x, why'd they remove it?

A question to Atmel.
However, Hapsim works slowly but quite nice - try yourself.
Here's a short example :

// główny moduł projektu
#define _MAIN_MOD_ 1

#define ENABLE_TX (UCSRB |= _BV(UDRIE))
#define DISABLE_TX (UCSRB &= ~_BV(UDRIE))

// pliki dołączone ( include ) :

#include 
#include 
#include 
#include 

// dane :

volatile bool NewChar;
volatile bool TxBusy;
volatile char UartChar;
volatile static int TxCounter;
volatile char TxBuffer[64];

const char Message1[] PROGMEM = "Hello Hapsim, can you hear me ?\n";
const char Message2[] PROGMEM = "Hello Hapsim, you asked for X message.\n";
const char Message3[] PROGMEM = "Hello Hapsim, you asked for Y message.\n";

// funkcje :

void SendString(PGM_P msg);
//---------------------------

void SendString(PGM_P msg)
{
 if (TxBusy) return;
 TxCounter=0;
 strcpy_P((char*)TxBuffer,msg);
 TxBusy=true;
 ENABLE_TX;
}

SIGNAL (SIG_UART_DATA)
{
 char k;
 k=TxBuffer[TxCounter++];
 if (k) UDR=k; else {DISABLE_TX;TxBusy=false;}
}

SIGNAL (SIG_UART_RECV)
{
 UartChar=UDR;
 NewChar=true;
}



//====================
// funkcja main()
int main(void)
{
 // inicjalizacja
 
 // ==== single usart configuration ====
 // 19200 baud with 8000 kHz osc./error=0,2%
 // data 8/stop 1/parity NONE
 // receiver ON/transmitter ON/recv interrupt enabled
 UBRRH = 0x00;
 UBRRL = 0x19;
 UCSRA = 0x0;
 UCSRB = _BV(RXEN) | _BV(TXEN) | _BV(RXCIE);
 UCSRC = _BV(URSEL) | _BV(UCSZ0) | _BV(UCSZ1);
 // ==== end usart ====

 sei();
 
 SendString(Message1);
  
 // pętla główna
 while (1)
  {
   if (NewChar)
      {
       NewChar=false;
       switch(UartChar)
         {
          case 'x': SendString(Message2); break;
          case 'y': SendString(Message3); break;
          default : break;
         }
      }// end NewChar
  }
}

Best regards Jurek S.

Attachment(s):