| Author |
Message |
|
|
Posted: Nov 09, 2010 - 08:37 PM |
|


Joined: Jul 18, 2005
Posts: 62371
Location: (using avr-gcc in) Finchingfield, Essex, England
|
|
|
Quote:
I'm not familiar with this instruction, is it something you place in the code? or you just do it with the AVRStudio?
When ATmega128's ship from Atmel they actually have the M103C fuse enabled (set to 0) so behave functionally like an ATmega103 not an ATmega128 which means a different memory map and limited functionality. |
_________________
|
| |
|
|
|
|
|
Posted: Nov 09, 2010 - 09:03 PM |
|

Joined: Feb 12, 2005
Posts: 16336
Location: Wormshill, England
|
|
1. I would guess your commercial board will already have the correct fuses.
2. I copy-pasted your program and compiled it. It works just fine. I vary a potentiometer on PORTF.0. The display varies from 1 to 255.
Your first job is to say what programmer you are using.
CodeVision is lovely for Edit-Compile-Burn-Run cycles.
However the 'Fuse Selection' requires a better brain than I possess.
I recommend that you go to http://www.engbedded.com/fusecalc/
Choose your fuses carefully, and then tick the CodeVision boxes exactly the same.
Personally, I always choose to NOT touch fuses with CodeVision. If I want to change fuses, I do it with Studio or avrdude.
After all, you normally set the fuses once, and this stays for 99% of projects with that AVR.
David. |
|
|
| |
|
|
|
|
|
Posted: Nov 09, 2010 - 09:18 PM |
|


Joined: Feb 19, 2001
Posts: 25923
Location: Wisconsin USA
|
|
|
Quote:
Quote:
In particular, examine the ADMUX bits for reference selection.
ADC channels 0-7, PF0-PF7.
That only deals with channel selection. How about the reference selection?
But than you did post your code, and we find:
Quote:
#define ADC_VREF_TYPE 0x60
...which is why I said earlier...
Quote:
In particular, examine the ADMUX bits for reference selection. Are they the same in both datasheets? What do you have connected to the AVCC, AGND, and AREF pins?
... and which seems to be indeed AVCC reference and ADLAR. Now, what else does the datasheet say about this?
Quote:
0 1 AVCC with external capacitor at AREF pin
If you do indeed have an input on your board to the AREF pin, then you selections have made AVCC fight with the voltage being applied to the AREF pin. Look at the diagram in the datasheet (notice how many times that word is mentioned?) and in some cases you can quickly fry your AVR with fighting voltages.
So get the schematic of the board you are using, determine what reference selection it is wired to use, and make code accordingly.
Lee |
|
|
| |
|
|
|
|
|
Posted: Nov 10, 2010 - 06:45 AM |
|

Joined: Oct 11, 2010
Posts: 6
|
|
|
Quote:
2. I copy-pasted your program and compiled it. It works just fine. I vary a potentiometer on PORTF.0. The display varies from 1 to 255.
Nice, did you modify anything in the code? or do you have an Atmega128 as well? What did you plug physically to your uC.
Quote:
Your first job is to say what programmer you are using.
I use Codevision to generate my code, and then use the HEX file and program it in the AVRStudio 4.
Quote:
After all, you normally set the fuses once, and this stays for 99% of projects with that AVR.
Could you explain which fuses I would be needing for this project only? And maybe why?
Today at school, I was talking to a friend who's uC arrived at the same time as mine since we ordered it together (same brand, same uC, same store) and she was telling me how she had the same problem when utilizing the ADC channel, she said that the value it returned was always at the highest, in my case "255".
And that she tried the code with a uC of a professor that is 1 or 2 years older (in version), and that it worked perfectly.
I'm starting to think that some or the whole shipment of uC's from were I got mine, are defective. Has this happened in the forums before? And if so, what do people do, other than cry?
Regards,
Ulysses L. |
|
|
| |
|
|
|
|
|
Posted: Nov 10, 2010 - 10:18 AM |
|


Joined: Jul 18, 2005
Posts: 62371
Location: (using avr-gcc in) Finchingfield, Essex, England
|
|
|
Quote:
I use Codevision to generate my code, and then use the HEX file and program it in the AVRStudio 4.
The "programmer" in this context is the block of electronics that sits between the PC and the AVR board. As you say you use Studio it sounds like it could be AVRISPmkII, STK500, Dragon or something similar? |
_________________
|
| |
|
|
|
|
|
Posted: Nov 10, 2010 - 07:17 PM |
|

Joined: Oct 11, 2010
Posts: 6
|
|
|
clawson wrote:
Quote:
The "programmer" in this context is the block of electronics that sits between the PC and the AVR board. As you say you use Studio it sounds like it could be
AVRISPmkII, STK500, Dragon or something similar?
I'm sorry, I'm using a ET-AVR JTAG (RS232) V1.0
As I stated before, every other proyect has worked perfectly such as the blinking LED, USART0 communication, etc. Except for the ADC channel.
Regards,
Ulysses L. |
|
|
| |
|
|
|
|
|
Posted: Nov 10, 2010 - 07:36 PM |
|


Joined: Feb 19, 2001
Posts: 25923
Location: Wisconsin USA
|
|
|
Quote:
are defective. Has this happened in the forums before?
No. Unless you have counterfeit chips.
http://www.sparkfun.com/commerce/news.php?id=364
You are now bemoaning bad chips, without ever exploring the AREF connection/level situation. It can explain your results. And also can explain how your chip might have been blown. |
|
|
| |
|
|
|
|
|
Posted: Nov 10, 2010 - 10:57 PM |
|

Joined: Oct 11, 2010
Posts: 6
|
|
|
theusch wrote:
You are now bemoaning bad chips, without ever exploring the AREF connection/level situation. It can explain your results. And also can explain how your chip might have been blown.
Here's the part of the schematic that shows how AVCC and AREF are connected to my atmega128.
What should I look for? I have tried twice to code it with a voltage reference AVCC and AREF. But still nothing seems to work. |
|
|
| |
|
|
|
|
|
Posted: Nov 11, 2010 - 03:25 AM |
|


Joined: Feb 19, 2001
Posts: 25923
Location: Wisconsin USA
|
|
|
Quote:
I have tried twice to code it with a voltage reference AVCC
Yes, indeed. have you looked at the ADC diagram in the datasheet? when you make that selection, what voltage is the AVR presenting on the AREF pin? Answer: AVcc. What other voltage is being presented to that pin? Answer: Look at your schematic. You have fighting voltages. Who knows which one will win, or whether you AVR remains undamaged.
No, they aren't "bad chips".
Didja ever look at the levels on the pins as I suggested?
BTW, why are you asking about getting bad >>chips<< when apparently you are using a purchased module/dev board? I'm getting way confused. If you bought a board and it doesn't work, why aren't you asking questions of your vendor? |
|
|
| |
|
|
|
|
|
Posted: Nov 06, 2011 - 03:04 PM |
|

Joined: Nov 06, 2011
Posts: 1
|
|
thx for ...
Code:
read_adc(0)
|
|
|
| |
|
|
|
|
|