View previous topic :: View next topic |
Author |
Message |
sato
Joined: 07 Apr 2007 Posts: 107
|
Posted: Sat May 17, 2008 7:43 pm Post subject: Atmega48 - If i use the internall oscilator... |
|
|
Hello
In my new project i want use Atmega48 and i need all the pins of the controller, the question is: If i use the internall oscilator can than use
Pb6 and Pb7 as normal input/output pins?
If yes, is the internal 8Mhz oscilator precise enough for serial communications baud 9600
Thanks
Regards
Sato |
|
Back to top |
|
|
jrkahrhoff
Joined: 25 Jan 2006 Posts: 169
|
Posted: Sun May 18, 2008 4:34 am Post subject: |
|
|
Hello and...
From the datasheet:
Quote: |
• XTAL2/TOSC2/PCINT7 – Port B, Bit 7
...In this mode, a crystal Oscillator is connected
to this pin, and the pin cannot be used as an I/O pin.
|
Looks like it!! Still you may want to wait for the experts to check in on this subject!
John |
|
Back to top |
|
|
Jabberwocky
Joined: 19 Jan 2005 Posts: 48
|
Posted: Sun May 18, 2008 7:59 am Post subject: |
|
|
Quote: | If i use the internall oscilator can than use
Pb6 and Pb7 as normal input/output pins? |
YES
Quote: | If yes, is the internal 8Mhz oscilator precise enough for serial communications baud 9600 |
It may work sometimes and most of the time it may not. The frequency of the internal RC-oscillator (+/- 3% and more) is not accurate and stable enough for asynchronous communication. You may be able to get a variability of around +/- 1% by calibrating the RC-oscillator (OSCCAL-Register), but you will still have a drift with temperature and time. You may also try lower baud rates (2400) with a bit more success though.
Kind regards
Neni |
|
Back to top |
|
|
Arera
Joined: 23 Sep 2007 Posts: 386 Location: Wuppertal, Germany
|
Posted: Sun May 18, 2008 10:20 am Post subject: |
|
|
Jabberwocky is right.
But I experienced no problems with internal osz. 8 MHz and 9600 BAUD when sending only a few bytes. I think frequ. deviation becomes a problem when sending larger amounts of data.
So, if you are not planning any live-protective apliance, give it a try! |
|
Back to top |
|
|
for_ro
Joined: 11 Nov 2007 Posts: 260
|
Posted: Sun May 18, 2008 12:17 pm Post subject: |
|
|
Hi,
actually, my experience is the opposite.
I have used several Mega128 with 16MHz and a baudrate of 115200 to communicate with various PCs.
If you believe the Bascom calculation this leads to an error of 7.84%.
The communication is done via a Max232. I am using hterm on the PC.
I have not seen any problems with transferring data at that speed. The cable has a length of 10m, sharing it with other signals like 1-wire and VCC as well.
So I don't undestand the histeria of reducing the error to less than 1%.
If you have a speed of 38400 at 8MHz, the error is 0.16%. With a max. of 3% deviation of the internal clock you are at less than half the error I have.
Regards
Rolf |
|
Back to top |
|
|
sato
Joined: 07 Apr 2007 Posts: 107
|
Posted: Sun May 18, 2008 12:24 pm Post subject: |
|
|
Hello
Thanks, if i can´t use the osc. pins for other purposes than i use a external cristal
Regards
Sato |
|
Back to top |
|
|
Arera
Joined: 23 Sep 2007 Posts: 386 Location: Wuppertal, Germany
|
Posted: Sun May 18, 2008 2:02 pm Post subject: |
|
|
@ rolf:
Your experience is not opposite to mine, but you expend it to higher baudrates.
@ sato
We came to the conclusion, that you CAN USE THE INTERNAL osz.!
Pins b6 ans b7 are free to be used as I/O! |
|
Back to top |
|
|
sato
Joined: 07 Apr 2007 Posts: 107
|
Posted: Sun May 18, 2008 3:31 pm Post subject: |
|
|
Hi again
Sorry i'm new to Atmegas
Second question:
I want programm the controller trough ISP, but i need every pin from the controller, can i use the Miso, Mosi, Sck for ISP programming and as normal I/O pin's to?
Thanks
Regards
Sato |
|
Back to top |
|
|
Jabberwocky
Joined: 19 Jan 2005 Posts: 48
|
Posted: Sun May 18, 2008 5:50 pm Post subject: |
|
|
Nobody said that one should keep the baud rate error below 1%. Atmel itself recommends errors mostly below 2%. With even lower baud rate errors the communication is just less prone to other overlaping errors (like noise etc.).
In the Atmel datasheets (for example on page 187 of the ATmega128-datasheet) there is a table with max. allowable (total) errors. For 8 data bits you can have a max error of up to +4.58/-4.54 % until you certainly get false data.
So an error of 7.84% (for 8 data bits) is simply not tolerable! But a baud rate of 115200 at 16 MHz will lead to an error of -3.5% and not 7.84%, so for_ro is just scratching at the limits of the specification (max total error: -4.54%). Since here a crystal (16 MHz) is used, there is mostly only this system-error (-3.5%), and oscillator variations (less than 100 ppm) can be left out of the game. Noise may play a role, but in this case (for_ro) it's obviously not a big issue.
So with an ATmega48 with internal RC-oscillator, which has a variability of 3% (factory calibrated) at 8 MHz (or 1 MHz resp. wth CKDIV8 programmed) and 25°C, it may work, but i wouldn't count on it. A small overlaping variability may result in very nasty communication errors. It depends also on how the device will be used (different temperatures, cable length etc.).
Kind regards
Neni |
|
Back to top |
|
|
sato
Joined: 07 Apr 2007 Posts: 107
|
Posted: Sun May 18, 2008 7:55 pm Post subject: |
|
|
Hello
My decision is a external cristal, but the second question is important for me now, the pins for ISP programming i need to drive a 7 segment display, can i config this pins as output and use always for ISP
programming?
Regards
Sato |
|
Back to top |
|
|
Jabberwocky
Joined: 19 Jan 2005 Posts: 48
|
Posted: Sun May 18, 2008 11:00 pm Post subject: |
|
|
Hi sato,
yes you can use the ISP-pins for other purposes too and still mantain the ISP-programming option. But depending on what you connect to the ISP-pins you may need to implement jumpers, switches etc. for the ISP-pins to isolate them from your display or whatever during programming. When you then want to program your chip via ISP, you can just set the jumpers/switches to the correct position.
Regards
Neni |
|
Back to top |
|
|
jenalcom
Joined: 10 Apr 2004 Posts: 365 Location: Perth, Western Australia
|
Posted: Mon May 19, 2008 3:24 am Post subject: |
|
|
If you make your 7 segment display plug in then you can just unplug ot and plug in your programmer. quick and easy!
With your question on baud rate - it is always better to get your % error to as low as possible unless you also have control over the % rate of the other unit that you are communicating with.
If you design your unit to have say +4% speed arror and the other unit is say -4% error then they will never communicate reliably. If on the other hand you can guarantee that your unit is say +10% (or any figure) and the other unit's error is the same then they will be quite happy talking to each other.
The point is that there are several de facto standards for baud rate but you generally never know how far off the other unit is unless you did the design yourself. Stick to +/- 2.5% max error rate and you should be OK normally. Stick to a much lower % if possible and it will make your life a lot easier in the long run.
Alan |
|
Back to top |
|
|
jrkahrhoff
Joined: 25 Jan 2006 Posts: 169
|
Posted: Mon May 19, 2008 4:39 am Post subject: |
|
|
Hi Again Sato,
In this thread:
http://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&t=5543
Luciano (the Guru of all things AVR) talks about using the hardware SPI for both ISP and I/O by using the 74HC4053 and the discussion also talks about another option: using a manual switch to toggle between states during program updates.
Is there any reason why you haven't decided to migrate to a different AVR with more I/O pins??
Just for the record, on my first three AVR projects I installed a crystal. However, now on my fourth (with a UART at 4800 baud), I am going WITHOUT the crystal to save board space. I do not anticipate any problems:-))
Regards,
John |
|
Back to top |
|
|
Luciano
Joined: 29 Nov 2004 Posts: 3149 Location: Italy
|
|
Back to top |
|
|
sato
Joined: 07 Apr 2007 Posts: 107
|
Posted: Mon May 19, 2008 10:37 am Post subject: |
|
|
Hello jrkahrhoff
Is there any reason why you haven't decided to migrate to a different AVR with more I/O pins??
The Atmega64 is expensive compared to Atmega48
I will make it with 4 Jmpers for the ISP pin's
Regards
Sato |
|
Back to top |
|
|
|