Calling all AVR wizards! (I need some more help!) Updated!

New stuff's in bold

I'm trying to build a clock-type-thing for my research project this year, and I need some help.

First, I need to know how I can run my ATtiny2313 off of a 12mhz external clock. No, not crystal, external clock. (this holds true)

Second, I need to know how to use interrupts (in general) to program a clock. I really just need some bare code or help, and any help is greatly appreciated.

So, I figured out how to use interrupts, and it's pretty simple, actually - I'm just having one small problem - why can't I write to global variables in an interrupt service routine (ISR)? Any clues on how I can talk back to the main routine from an interrupt?

Thanks!,
-Muffinator

Picture courtesy of Oskay!

Picture of Calling all AVR wizards!  (I need some more help!) Updated!
sort by: active | newest | oldest
1-10 of 37Next »
oskay9 years ago
CC-licensed picture!
Hey, that's my photo. I don't mind if you use it (that's what the CC license is for) but you really should give me credit, you know. Even the CC license says so.

Have you got your AVR cooperating fully now?
zachninme oskay9 years ago
He talked to me last night, and this seems to sum it up: So, I figured out how to use interrupts, and it's pretty simple, actually - I'm just having one small problem - why can't I write to global variables in an interrupt service routine (ISR)? Any clues on how I can talk back to the main routine from an interrupt? He also mentioned that the interrupts just stopped working about 30 or so, I'm not sure if he got that fixed...
Have you got your global ISR-modified variables declared as "volatile" ? If not, the compiler is likely to optimize away access to the variable in the non-interrupt code. (oh; I see gmoon has Already said this.)
T3h_Muffinator (author)  westfw9 years ago
Yep! I did that, and it works flawlessly! My only problems now are... well.... impossible. I'll see if I can type up the scenario.... but my dad's an EE major, and he said it's impossible too. I'll also double check all my connections, and see what the hell is going on with an o-scope. (excuse my language) Thanks for all the help, though. I really needed it!
Now we're all curious...
T3h_Muffinator (author)  gmoon9 years ago
Okay! Awesome! (well..... kind of......) So I gave up on that other project I was working on (for now), and now I'm working on the clock. I actually finished writing up a clock using the internal clock and ISR's , and now I'm going to try to burn the fuses and code a bit to make it run on the external! Hoorai! I might edit the post later on in the week and let you guys know what happened - but I'm on a huge timed deadline - I have until monday night to make a braille clock that sets itself via the WWVB signal... I still have to work on USART communication between this WWVB module I made and the uC, and that should be it! Sigh, that's still a TON of work, though (for me, at least)... I'm such a noobie! -Josh
Cool project(s)! Yeah, let us know how it shakes out--that's a lot of work to do in a couple days... (and make an 'ible, too.)
T3h_Muffinator (author)  gmoon9 years ago
The braille clock isn't actually "my" project..... I'm mentoring two juniors in my school's research program (I'm a senior). Unfortunately, I'm not that great of a teacher, and we're on a serious time limit, so I end up doing most of the work.

I'm going to have them write up an 'ible when we're done =)
T3h_Muffinator (author)  T3h_Muffinator9 years ago
By the way, after you burn fuses, do you have to re-burn them each time you program the chip? I'm having trouble programming my chip now that I burned the fuses so that it runs on an extermal oscillator (which is still attached)
(quick response, I'm on my way out...) Right--the clock source needs to be attached once you set that w/fuses. RE: ISP at higher speeds: I bricked a atmega8 by programming fuses (w/uisp) once it was running at 8mhz (I've not tried to recover it with HV programming on my STK500, yet.) The moral--your mileage will vary when using home-made DAPA parprot cables (length of the cable, parallel port differences, etc.) ISP programming itself should work at any speed, and is very reliable with the STK500, I'm told (I just haven't gotten around to using mine.) But there is a bitclock option in avrdude--that may allow you to tune it for the 12mHz clock...
1-10 of 37Next »