Forum Index > General > Ask an Evil Mad Scientist!
 Crystal
 |  Printable Version
By: Anonymous: linxdev@gmail.com () on Wednesday, August 24 2011 @ 12:28 PM PDT (Read 5285 times)  
Anonymous: linxdev@gmail.com

Just received an envelope of goodies. Got the Zif Mini Development kit.

My question is on the external clock. This kit did not come with a crystal but I do have them. If I DO add the rock do I need to change the fuse on the Mega to use an external clock? Or is it automatic? I've got a project where I want to see if the crystal is a benefit or not.

Thanks,
Chris





       
   
By: Windell (offline) on Wednesday, August 24 2011 @ 12:47 PM PDT  
Windell

First, you probably know this, but if you do add a crystal, you usually also need to add two small matching capacitors as well, and locations are provided on the PCB.

And then yes, you do need to change the fuse values on the AVR in order to change the clock selection. With the crystal in place, it can either use that crystal or continue to use its internal RC oscillator, depending on the fuse values that you select.

And, if you haven't seen it, the fuse calculator is awesome. Big Grin


Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Forum Evil Scientist
Evil Scientist

Status: offline

Registered: 06/15/06
Posts: 1932
Sunnyvale, CA

Profile Email Website  
   
By: Anonymous: linxdev () on Wednesday, August 24 2011 @ 12:59 PM PDT  
Anonymous: linxdev

Okay, If I understand this right that kit includes the 328 with the fuse already set to use only the internal clock. I'll build my circuit before I change this.

I have a ISP header and I have an AVRISP MKI (serial) flasher. Is there any danger of overwriting the bootloader on the chip provided by EMS?

Thanks,
Chris





       
   
By: Windell (offline) on Wednesday, August 24 2011 @ 01:09 PM PDT  
Windell

Okay, If I understand this right that kit includes the 328 with the fuse already set to use only the internal clock. I'll build my circuit before I change this.

Yes, the fuse settings should be factory-default. IIRC, that's running from the 8 MHz internal oscillator, with the divide-by-8 option set, for a net frequency of 1 MHz.

I have a ISP header and I have an AVRISP MKI (serial) flasher. Is there any danger of overwriting the bootloader on the chip provided by EMS?

If this is a chip that came with a mini-dev kit, there should not be a bootloader on it. And in any case, if you have an AVR ISP programmer, you can add a new bootloader whenever you like.


Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Forum Evil Scientist
Evil Scientist

Status: offline

Registered: 06/15/06
Posts: 1932
Sunnyvale, CA

Profile Email Website  
   
By: Anonymous: linxdev () on Thursday, August 25 2011 @ 06:25 AM PDT  
Anonymous: linxdev

I'm stuck and I'm not quite sure what I should do.

I've built the mini-dev and I've added the 16M crystal. Here is my program

PHP Formatted Code

void setup() {                
  delay(1000);
  Serial.begin(9600);
 
}

void loop() {
  Serial.println("TEST");
  delay(1000);              // wait for a second
}
 



I've got a snooper running and this is what I get:

PHP Formatted Code

0x54(T)
0x53(S)
0x0D
0x54(T)
0x0D
0x54(T)
0x0D
0x54(T)
 



I've tried two TTL to serial converters. One MAX232 to serial and the other the PL2303 to USB. Same results. If I drop speed down to 1200 it works fine.

Here are my fuse settings:

PHP Formatted Code

avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as D9
avrdude: safemode: efuse reads as 5
 



Any ideas of what I'm doing wrong?

Chris





       
   
By: Anonymous: linxdev () on Thursday, August 25 2011 @ 09:20 AM PDT  
Anonymous: linxdev

I'm really miffed now.

I built the Diavolino and uploaded this program

PHP Formatted Code

void _blink(unsigned int d) {
        digitalWrite(13, HIGH);
        delay(d);
        digitalWrite(13, LOW);
        delay(d);
}
void setup(void) {
        delay(1000);
        Serial.begin(9600);
        pinMode(13, OUTPUT);
        _blink(125);
        _blink(125);
        _blink(125);
}

void loop(void) {
        Serial.println("TEST");
        _blink(1000);
}
 



LED blinks fine but I get missed characters out of the serial port on 2 TTL adapters.





       
   
By: Windell (offline) on Thursday, August 25 2011 @ 10:56 AM PDT  
Windell

I've tried two TTL to serial converters. One MAX232 to serial and the other the PL2303 to USB. Same results. If I drop speed down to 1200 it works fine.


When enabled with the crystal-- and the fuse settings look like they could be correct --the AVR itself is capable of high-speed communication without issue, so the most likely circumstance is that something else is going on. Unfortunately, you are testing a lot of things at once here, and you haven't given nearly enough information for me to guess where the problem is.

But... some of the things that I would check include the following:

- Is it possible that the timebase is incorrect, despite appearances?
-- What crystal frequency is being used? If it's not 16 MHz, then are the baud rates calculated correctly?
-- Is the crystal type correctly matched to the fuse settings? Is it a "full swing" or "low power" crystal?
-- Are the capacitors correctly matched to the capacitance of the crystal?

- What type of power supply is being used?
--Is it in the range 4.5 - 5.5 V DC, assuming that you're between 10 MHz and 20 MHz?
--How quiet is the power supply? Are there spurious signals that could be feeding into the serial communications? Would additional filters on the supply help?
--How are the voltage levels of the AVR matched to the voltage levels that the serial converters expect on their inputs/outputs?
-- Does the power supply have sufficient current capacity to avoid dropouts or brownouts when the AVR or the serial converter changes state?

- Are the serial converters (MAX232/PL2303) working correctly?
-- Have these been tested independently to work with any other communications device, or perhaps, through each other?
-- Is there any chance that there is not a reliable ground connection between the AVR power supply and your computer/serial interface?
-- Is there any chance that you're seeing ground-loop effects on that same connection?
-- Does shielding the cabling make any difference?

- Is your computer end of things configured properly?
-- Any chance that you have an unusual protocol specified on the receiving end?
-- Are your dropouts reasonably consistent, or are there other factors that seem to influence the communications?
-- Do things work better communicating from the two AVRs directly to each other, without your computer in the loop?


Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Forum Evil Scientist
Evil Scientist

Status: offline

Registered: 06/15/06
Posts: 1932
Sunnyvale, CA

Profile Email Website  
   
By: Windell (offline) on Thursday, August 25 2011 @ 11:14 AM PDT  
Windell

Quote by: linxdev

I'm really miffed now.

I built the Diavolino and uploaded this program

LED blinks fine but I get missed characters out of the serial port on 2 TTL adapters.


Being miffed at us isn't going to solve your serial hardware issues.
The program works here, so it's likely not a firmware issue.

I'm guessing that you uploaded the program through the ISP programmer rather than through one of the serial interfaces. Do you have any independent confirmation that these interfaces are working how you would expect?


Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Forum Evil Scientist
Evil Scientist

Status: offline

Registered: 06/15/06
Posts: 1932
Sunnyvale, CA

Profile Email Website  
   
By: Anonymous: linxdev () on Thursday, August 25 2011 @ 11:57 AM PDT  
Anonymous: linxdev

Both TTL adapters work with other devices. One was used to control a radio using software. The other I had installed in a GPS receiver for my car and cut it out of that circuit to try on this.

The crystals in both circuits are from your stock. One came with the Diavolino. The other I ordered when i bought the rest of the goodies.

I've tried two power supplies. I tried a 12v SLA with a 7805 converter tat I built. I then tried power directly off the USB bus of the computer.

I may try a different PC. My office is noisy (RF) but I never experienced an issue on the UNO. The USB to TTL is about 6' long. The MAX232 is on a PCB with leads only 2" long.

I'm thinking that since I have replicated this on two chips that there must be something external giving me grief.





       
   
By: Anonymous: linxdev () on Thursday, August 25 2011 @ 12:03 PM PDT  
Anonymous: linxdev

4.9v off USB bus on computer.

2.9v off TX line to TTL converter.





       
   
By: Anonymous: linxdev () on Thursday, August 25 2011 @ 12:08 PM PDT  
Anonymous: linxdev



That is the compiled code. If you can load it on your I can rule out compiling issues.

Chris





       
   
By: Windell (offline) on Thursday, August 25 2011 @ 12:20 PM PDT  
Windell

Both TTL adapters work with other devices. One was used to control a radio using software. The other I had installed in a GPS receiver for my car and cut it out of that circuit to try on this.

OK-- great. It might still be worth trying a "loopback test" (serial-TTL-serial) with the two of them.

>The crystals in both circuits are from your stock.

Great-- I'm quite familiar with these. Big Grin And it's the right "low-power" type for those fuse settings.

>I tried a 12v SLA with a 7805 converter tat I built. I then tried power directly off the USB bus of the computer.

The 12V SLA/7805 should be as quiet as possible, and 5V from USB is usually good enough as well.

>My office is noisy (RF) but I never experienced an issue on the UNO.

Could you try talking to the UNO with your two serial interfaces? D0 and D1 should be accessible, and lightly isolated (through 1k resistors) from the 8U2.


Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Forum Evil Scientist
Evil Scientist

Status: offline

Registered: 06/15/06
Posts: 1932
Sunnyvale, CA

Profile Email Website  
   
By: Anonymous: linxdev () on Thursday, August 25 2011 @ 12:29 PM PDT  
Anonymous: linxdev


Could you try talking to the UNO with your two serial interfaces? D0 and D1 should be accessible, and lightly isolated (through 1k resistors) from the 8U2.



This is an excellent idea I have not thought of. I will try this.





       
   
By: Anonymous: linxdev () on Thursday, August 25 2011 @ 12:59 PM PDT  
Anonymous: linxdev

Quote by: linxdev


Could you try talking to the UNO with your two serial interfaces? D0 and D1 should be accessible, and lightly isolated (through 1k resistors) from the 8U2.



This is an excellent idea I have not thought of. I will try this.



Works great. Adapters are good.





       
   
By: Anonymous: linxdev () on Thursday, August 25 2011 @ 01:13 PM PDT  
Anonymous: linxdev

I'm really curious as if it could be an issue when compiling. I'm not using the IDE. I've got a Makefile and am using VIM as my IDE. I spent the time to figure out how to do it on the CLI after a day of using the IDE. I have been programming the UNO using CLI too.

I've changed the code and it now works.

PHP Formatted Code

void _blink(unsigned int d) {
        digitalWrite(13, HIGH);
        delay(d);
        digitalWrite(13, LOW);
        delay(d);
}

void _print(char *m) {
        char *ptr;
        for(ptr = m; *ptr; ptr++) {
                Serial.print(*ptr);
                delay(50);
        }

        return;
}
void setup(void) {
        delay(1000);
        Serial.begin(9600);
        pinMode(13, OUTPUT);
        _blink(125);
        _blink(125);
        _blink(125);
}

void loop(void) {
        _print("TEST\r\n");
        _blink(1000);
}
 



If I delay 50ms between each char it works well.





       
   



 All times are PDT. The time is now 06:13 AM.
Normal Topic Normal Topic
Locked Topic Locked Topic
Sticky Topic Sticky Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Able to Post 
Filtered HTML Allowed 
Censored Content 

Evil Mad Scientist Forum Archives — Read only!

Please visit our new forums for new discussions.


DIY Hardware for Electronic Art


The Original Egg-Bot Kit


Octolively
Interactive LED kits


Meggy Jr RGB
LED matrix game
development kit.


Business-card sized
AVR target boards


Peggy 2
LED Pegboard kits

My Account






Lost your password?