Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
April 25, 2024, 06:51:38 06:51


Login with username, password and session length


Pages: [1]
Print
Author Topic: Serial Port Example AVR using Crosswork AVR  (Read 4974 times)
0 Members and 1 Guest are viewing this topic.
edi14_10
Junior Member
**
Offline Offline

Posts: 45

Thank You
-Given: 2
-Receive: 7


« on: December 06, 2007, 03:50:15 15:50 »

does anyone have an example using serial port in avr using crosswork AVR compiler?
Logged
zetd
Junior Member
**
Offline Offline

Posts: 68

Thank You
-Given: 18
-Receive: 32


« Reply #1 on: December 06, 2007, 04:35:48 16:35 »

Hire is my test on Rowley Crosswork for AVR

credit is for [email protected]
http://www.holger-klabunde.de/index.html

i just mod his code and port from winavr (GNU) syntact to Rowley Crosswork for AVR (Actually GNU variant too)


hey edi14_10, try to port this library http://hubbard.engr.scu.edu/embedded/ , i have done with it


use for your reference

Logged

Dreams really do come true, when home robots do the dirty work for me. everythink is free, no war, no poison on my earth, everyone share thinks but not with my pretty girls,powered by science and humanity not by "dazzle think" - welcome to the planet of earth -
preecha
Guest
« Reply #2 on: December 10, 2007, 08:54:25 08:54 »

for Crosswork AVR 1.3

#define BAUD 57600    //Enable 2x speed     28800 x 2 = 57600
#define BAUDRATE FOSC/16/BAUD-1
void USART_Init(unsigned int baudrate)
{
     
    UBRRH =  (unsigned char)(baudrate>>Cool;
    UBRRL =  (unsigned char)baudrate;
   
    // Enable 2x speed
    UCSRA = (1<<U2X_BIT);

    // Enable receiver and transmitter
    UCSRB = (1<<RXEN_BIT)|(1<<TXEN_BIT)|(1<<RXCIE_BIT);

    // Async. mode, 8N1
    UCSRC = (1 << URSEL) | (3 << UCSZ0);
}
void TxSerialPort(unsigned char data)
{
     while (!(UCSRA & (1<<UDRE_BIT)));
    UDR = data;
   
   
     
}
unsigned char RxSerialPort(void)
{
    while (!(UCSRA & (1<<RXC_BIT)));
    return UDR;
}
void main()
{
  unsigned char dat;
  USART_Init(BAUDRATE);
  while(1)
  {
     dat=RxSerialPort();
     TxSerialPort(dat);
  }
 
}
Logged
edi14_10
Junior Member
**
Offline Offline

Posts: 45

Thank You
-Given: 2
-Receive: 7


« Reply #3 on: December 11, 2007, 12:14:14 00:14 »

How about delay in crosswork? i didnt find delay.h. do we have to make the library by ourself?
Logged
metal
Global Moderator
Hero Member
*****
Offline Offline

Posts: 2420

Thank You
-Given: 862
-Receive: 678


Top Topic Starter


« Reply #4 on: December 11, 2007, 02:01:44 14:01 »

delay cycles should work for you
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC