Attiny2313 external clock

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Attiny2313 external clock

Postby eventhorizon » Fri May 27, 2011 12:48 pm

Recently I have been playing with my tiny2313 and I was planning on making a binary wall clock with it for my project. Since the internal clock is unreliable when it comes to time keeping I placed an 8 mhz crystal and programmed the fusebits. I've mistaken "External clock" for "External Crystal" and now my tiny2313 cannot be read by my PC. I've done my research and it says to use a square wave generator (i.e. an astable 555 circuit). But what frequency do I exactly need for an external clock? I really need you help ASAP..
-----------------------------------------------------------------------------------------------
Out of one hole, and into another.
eventhorizon
 
Posts: 114
Joined: Tue Jan 25, 2011 5:09 pm
Location: Quezon City, Philippines

Re: Attiny2313 external clock

Postby eventhorizon » Fri May 27, 2011 12:51 pm

Correction: What I mean is I mistakenly programmed the tiny2313 for "External clock" Instead of programming it with "External 8mhz crystal". So with that the 8 mhz crystal is useless...:(
-----------------------------------------------------------------------------------------------
Out of one hole, and into another.
eventhorizon
 
Posts: 114
Joined: Tue Jan 25, 2011 5:09 pm
Location: Quezon City, Philippines

Re: Attiny2313 external clock

Postby JChristensen » Fri May 27, 2011 1:55 pm

It shouldn't be terribly critical. I'd shoot for something between 100kHz and 1MHz.
JChristensen
 
Posts: 106
Joined: Mon Jan 03, 2011 10:45 am

Re: Attiny2313 external clock

Postby eventhorizon » Sat May 28, 2011 12:39 am

Update: I don't know if an NE555p Timer set to astable works at 1 mhz (R1 = 1k, R2 = 2k, C = 480pf), but I expected it to not work because 555 timers are unreliable at that frequency. so I lowered it down to like 500 khz and still my tiny2313 can't be read. BTW, to clear things up I'm connecting Pin 3 of the 555 Timer to XTAL1 (Pin 5 of tiny2313), or am I doing it wrong? Also I've read from somewhere before that they used another AVR as a square wave generator. I have a spare tiny2313, how do I exactly program it to output 1 mhz?
-----------------------------------------------------------------------------------------------
Out of one hole, and into another.
eventhorizon
 
Posts: 114
Joined: Tue Jan 25, 2011 5:09 pm
Location: Quezon City, Philippines

Re: Attiny2313 external clock

Postby mtbf0 » Sat May 28, 2011 7:19 am

Code: Select all
void main (void) {
  while (1)  PORTB ^= 1 << PB1;
}


or use a timer. this one is probably more like 2MHz on an 8MHz 2313 assuming the the generated code reads the port, toggles the bit, writes the port and jumps. the square wave will be on port B, pin 1.
"i want to lead a dissipate existence, play scratchy records and enjoy my decline" - iggy pop, i need more
User avatar
mtbf0
 
Posts: 1642
Joined: Fri Nov 09, 2007 11:59 pm
Location: oakland ca

Re: Attiny2313 external clock

Postby eventhorizon » Sat May 28, 2011 10:07 am

I'm still not having luck with it. I tried something similar with another 2313 on 8 mhz crystal, running at 1 mhz (with DIV8 fuse of course). I'll disable the DIV8 fuse to get 8 mhz out of it.. thanks for the replies guys..:)
-----------------------------------------------------------------------------------------------
Out of one hole, and into another.
eventhorizon
 
Posts: 114
Joined: Tue Jan 25, 2011 5:09 pm
Location: Quezon City, Philippines

Re: Attiny2313 external clock

Postby eventhorizon » Sat May 28, 2011 11:31 am

Somehow I kind of remembered that when I accidentally programmed it to external clock, I also didn't remove CKDIV8. So I guess it's CKDIV8 that's been messing with the clock, so 1 mhz would be divided by 8, and so on.

Update: I tried using my spare tiny2313 with external 8 mhz crystal (this time without CKDIV8 to get full 8 mhz out of it) and using this code:
Code: Select all
#include <avr/io.h>
int main(){
   DDRB = 0x01;
   while(1){
      PORTB ^= (1<<0);
   }
}


Sadly I don't have an oscilloscope so I can't verify if this is really making a clean 8 mhz square wave(or 2 mhz). Also the Fusebits of my (slight) dead tiny2313 is lfuse[0x60], hfuse[0xDF], and efuse[0xFF]. I'm feeding the clock signal at Pin 5 (XTAL1) of the dead tiny2313.
-----------------------------------------------------------------------------------------------
Out of one hole, and into another.
eventhorizon
 
Posts: 114
Joined: Tue Jan 25, 2011 5:09 pm
Location: Quezon City, Philippines


Return to Microcontrollers

Who is online

Users browsing this forum: No registered users and 2 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [102]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
BeagleBone[24]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[33]
LCDs & Displays[48]
Components & Parts[69]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[109]
 
Wireless[14]
Cables[60]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[70]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]