Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] [ASK ]Can i use UART, SPI, and I2C/TWI together at the same time (ATMEGA32)??

Status
Not open for further replies.

ventisca

Newbie level 4
Newbie level 4
Joined
Aug 18, 2012
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,330
Hi all.

Can i use UART, SPI, and I2C/TWI together at the same time on ATMEGA8535/ATMEGA16/ATMEGA32 ?

The truth is i make a program that use UART, SPI, and I2C together but there is some error when i test the module using UART, SPI, and I2C.

uC : ATmega32
SPI : ENC28J60 (ethernet controller)
I2C : DS1307 (RTC)
UART : Leadtek 9540 (GPS receiver)

Thank you.
 

There are two things that would prevent you from using all three communications protocols at the same time...

1. If there is a pin conflict. It would be worthwhile, regardless of your processor choice, to make sure that your uC has enough pins as to support all three protocols on separate pins without having to reconfigure the pins each time you want to use a different protocol. It would be impractical, from my experience, to try to use all three if they share pins, because this would mean having to perform low-level configurations each time you wanted to use a different protocol.

2. If you have a communications "module" that supports multiple protocols instead of the different individual peripherals. An example would the the USCI, or "Universal Serial Communications Interface", of the TI MSP430 family. This is a module that allows the user to configure it for either SPI, UART, or I2C. Having to use a single module and reconfigure it hundreds of times a second in order to communicate on all three protocols would be very difficult and incur a lot of overhead. That being said, if you had three of these USCI modules (just as an example), then you would be in the clear.

I hope this makes sense. I would consult the data sheets and make sure that you have the ability to pin out the various communications peripherals to separate pins, and that the communication suites are actually different protocols. I wish I could be more help, but unfortunately I can only offer advice, as I have never used any of Atmels chips.

Regards,
Willis
 
If there is no pin conflict, and configurations allow you to enable all the modules same time; that is ok.
 
There are two things that would prevent you from using all three communications protocols at the same time...

1. If there is a pin conflict. It would be worthwhile, regardless of your processor choice, to make sure that your uC has enough pins as to support all three protocols on separate pins without having to reconfigure the pins each time you want to use a different protocol. It would be impractical, from my experience, to try to use all three if they share pins, because this would mean having to perform low-level configurations each time you wanted to use a different protocol.

2. If you have a communications "module" that supports multiple protocols instead of the different individual peripherals. An example would the the USCI, or "Universal Serial Communications Interface", of the TI MSP430 family. This is a module that allows the user to configure it for either SPI, UART, or I2C. Having to use a single module and reconfigure it hundreds of times a second in order to communicate on all three protocols would be very difficult and incur a lot of overhead. That being said, if you had three of these USCI modules (just as an example), then you would be in the clear.

I hope this makes sense. I would consult the data sheets and make sure that you have the ability to pin out the various communications peripherals to separate pins, and that the communication suites are actually different protocols. I wish I could be more help, but unfortunately I can only offer advice, as I have never used any of Atmels chips.

Regards,
Willis

If there is no pin conflict, and configurations allow you to enable all the modules same time; that is ok.

===============================================================================================================

Thank you.

The uC has the different fixed pin for each interface protocol (except for I2C that i can freely configure it everywhere).
So i'm sure that there is no pin conflict.

The component that use USCI or support different interface protocol is kinda rare and more expensive here in Indonesia. :)
I's look like i will try that if there is no other way to make the current system work.

I have some error when i use SPI and I2c together and i found this post
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=940435
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=956822

They have similiar problem when interfacing the device with SPI and I2C at the same time.
So i want to make sure that it's not a interface protocol problem before i debug the program.

The problem is the I2C works normally when i test it individually, but the error occur when i use I2C and SPI together.
The RTC DS1307 send a random value (time and date) and when i remove the ENC28J60, the RTC work just fine.

Thank you very much. :D
 

The uC has the different fixed pin for each interface protocol (except for I2C that i can freely configure it everywhere).
Means you are using a software I2C master. ATmega has a hardware I2C, with fixed unique pins. Both should work independent of SPI.
 

Means you are using a software I2C master. ATmega has a hardware I2C, with fixed unique pins. Both should work independent of SPI.
Yes, i think the compiler (CVAVR) configure the I2C pin using it's library trough software, although the atmega has the dedicated pin for I2C, and the pin is independent with other interface protocol.

How to use the "hardware" pin for I2C on atmega? (the I2c dedicated pin on PC0 and PC1)
is there any special configuration for this?
 

I would expect library support for hardware I2C. Otherwise you need to set the special function registers respectively, it's all in the processor datasheet.
 

your crystal value please....Are you using internal crystal or ext ? give safes ant CRY...............

- - - Updated - - -

you have to check the crystal value .. if you did not give the enough crystal for this communications.. refer data sheet and give enough crystal..
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top