UART for Attiny44

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

Hi, could someone help me with a code example for uart attiny44.

Am unable to get the uart communication. when am receving the data from uart its getting garbage values.

This topic has a solution.
Last Edited: Thu. Aug 10, 2017 - 05:10 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Post your code here using <> button. Maybe someone can help you.
.
MG

I don't know why I'm still doing this hobby

Last Edited: Wed. Aug 2, 2017 - 07:37 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

See my sig - the problem is almost certainly a question of clock rates and timing.

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

Let me guess, your using the internal R/C at 1MHz and using 9600 baud, right?

 

The tiny44 does not have a usart! 

 

Jim

 

Last Edited: Wed. Aug 2, 2017 - 01:05 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ah but it does have the half-arsed USI:

 

so maybe:

 

http://www.atmel.com/Images/doc4...

 

that is...

 

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

I have no love for ATtiny's.

For my reasoning I refer to my (lengthy) posts in these 3 links:

http://www.avrfreaks.net/forum/a...
http://www.avrfreaks.net/forum/a...
http://www.avrfreaks.net/forum/a...

 

And I also want to advise to get yourself  one (or a few) cheap logic analysers from Ali/Ebay.

These are wonderfull for debugging problems like this.

I've posted many times before about this. Read up on the links in:

http://www.avrfreaks.net/search/...

Paul van der Hoeven.
Bunch of old projects with AVR's:
http://www.hoevendesign.com

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

You might want to check out the software UART by Danni at https://community.atmel.com/projects/software-uart-fifo  Its target is an ATtiny44 and does not use the USI.  Using an ATtiny84, I'm about to try the Danni UART and a USI UART from mikrocontroller.net referenced in http://www.avrfreaks.net/forum/using-usi-uart-attiny-254585 .

 

Both UARTs are implemented in C and use Pin Change interrupts to detect when a character is been received. Both implement xmit and receive FIFOs.  However, Danni's UART uses Timer1 to trigger interrupts, rather than Timer0 to time USI events. The mikrocontroller code uses Timer0 and the USI register (only the header file is in German)smiley.

 

Good luck,

Alan

microcontroller URLs

https://www.mikrocontroller.net/attachment/18859/USI_UART.c

https://www.mikrocontroller.net/attachment/18859/USI_UART.h

Last Edited: Wed. Aug 2, 2017 - 08:03 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Am unable to get the uart communication. when am receving the data from uart its getting garbage values.very

Do you possibly only need to transmit from the tiny44 (such as to report some sensor values)...that is much simpler & you'd be less likely to "rcv garbage"  at the other end of the line.  Going the other way is tougher but do-able.

When in the dark remember-the future looks brighter than ever.

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

this is my code.. am not able to get the Communication. where the problem am unable to get it. 

plese can any one help me.

 

thnaks.

Attachment(s): 

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

AVR307 is taking as a reference. but am not getting  the comminication. could you plese help me where am doing wrong. my code is posted above.

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

When you expect someone to help you, you better provide "ALL" the project you tried and failed. So maybe someone want to / can help you.

If your project code is classified, at least after you "cut it", try it that it can be compile correctly so someone don't wasted his time to do the searching where the compile error is.

Where's is the "USI_UART_config.h" ? and the LCD file which you define "LCDBL_DS" ? 

Maybe someone want to help you with this.

 

 

 

MG

I don't know why I'm still doing this hobby

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

this is my code.

 

 

 

Its wirking.

 

the proble with the fuse bits.

 

Attachment(s): 

Last Edited: Thu. Aug 10, 2017 - 05:12 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
USI_UART_Initialise_Transmitter is not being called.

 

Edit: In the last upload there is a call to USI_UART_Initialise_Transmitter, but the whole transmitting part is commented out.

Stefan Ernst

Last Edited: Thu. Aug 3, 2017 - 06:02 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i wanna to receve olny .. the receved data is displayed on lcd. no need for transmit.

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

If the project requires uart comms, why did you pick an AVR that does not have a uart? 

For successful serial comms, you need an accurate and stable clock source, do you have one?  xtal?

 

Jim

 

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

srinivasp,

 

Did you find a solution to your problem?

 

I got both the Danni SW code and the microcontroller (AVR307) code to work on an ATtiny84 so it should work on the ATtiny44.

  

The Danni code worked immediately after compiling.  Adaptation of the AVR307 code to the ATtiny84  took a while since I had to learn

what was going on with the USI code and found that the Timer0 prescaler had to be changed for the combination of clock speed and

BAUD rate.  I also rearranged the source and header files to put all (but the prescaler bit states at this point) adaptation data in the header file.

 

If you are interested, I will zip the adapted AVR307 code and upload it to this thread.  I used the 8MHz internal clock and 19200

BAUD since those two parameters yields a near-integer ratio of clock to BAUD rate.  The code was compiled with WINAVR (avr-gcc)

in an Eclipse environment, has a main function for testing and contains lots of original (and my) comments in 80 column format of my discoveries.

 

Alan

 

P.S Just noticed in your Interrupt handlers section, the ISR should be ISR(PCINT0_vect), not ISR(PCINT6_vect).  I'm a bit surprised you did not

get a compile error since PCINT6 is not in the vector list.

Last Edited: Wed. Aug 9, 2017 - 05:42 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

allano wrote:
I will zip the adapted AVR307 code and upload it to this thread

So upload it. Maybe others has the same problem.
.
MG

I don't know why I'm still doing this hobby

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

The OP did say that he solved his problem but I will attach my files since they deal only with the USI UART for the tiny and are organized in more of a pseudo library fashion (used by placing the .c and .h files in a project's workspace ). 

 

All of the adaptation for any added tiny microcontrollers is performed in the header file by choosing different #define statements and adding the applicable register names in a #ifdef (__AVR_ATtinyxx__) section.  MACROs calculate the parameters needed to use the USI as a UART.

 

Alan

Attachment(s): 

Last Edited: Thu. Aug 10, 2017 - 05:24 PM