Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

I would like to set my AVR's OSCCAL for proper RS-232 communication using the other end's transmission as the calibration clock, without having to solder the RX pin to a timer pin. Is there firmware to do this?


edit
I wound up writing my own synchronization routine and soldering the RX pin to the ICP (input capture) unit. When the ICP pin changes, TIMER1's value is copied into a register and an interrupt fires.

The code uses an ADCPM-inspired search technique. OSCCAL is incremented or decremented by 1 initially. Each time OSCCAL needs to move in the same direction again it moves twice as far, when it switches direction it starts over at 1. http://code.google.com/p/pwmsign/source/browse/synch.c

All that trouble, and I discovered the perfect OSCCAL was only 1 off from the factory setting.

share|improve this question
    
If you give me a link to the associated docs, I should be able to take a look tomorrow and help out. –  Kortuk Jun 16 '10 at 22:24
    
what do you mean by 'proper UART communication'? you don't need clock synchronization between the AVR and the other end of the UART to make it work. I guess maybe if your bit banging the UART on the AVR end which i find unlikely. –  Mark Jun 17 '10 at 3:12
    
@Mark I mean the TX clock of the AVR has to match the RX clock of the PC within a few % and vice versa, not guaranteed without an XTAL. –  joeforker Jun 17 '10 at 15:21

1 Answer 1

Clearly I'm looking for the Atmel-provided datasheet, AVR054: Run-time calibration of the internal RC oscillator. I think it could be adapted to PC-to-AVR communication without too much trouble...

share|improve this answer
1  
Why is this an answer? –  Kortuk Jun 17 '10 at 17:29
    
I am using an ATtiny2313 which does not have e.g. a PCINTn on the RX pin. So I think the answer is to use AVR054 and go ahead and solder RX to INT0. –  joeforker Jun 17 '10 at 20:19
    
No, I think you are miss-understanding. –  Kortuk Jun 18 '10 at 3:47
    
@Kortuk I would be very happy to get another answer, but my answer to my own question is 'go ahead and solder two pins together and use AVR054'. –  joeforker Jun 18 '10 at 12:55
    
I was asking for links to your datasheet. I will write and answer when I confirm I am not misunderstanding. I do not think you need the cal feature at all. –  Kortuk Jun 27 '10 at 15:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.