Atmel Attiny 4313 External Crystal Clock - Page 1
Forum section: electronics / general

author: firstoption
author_rank: Newbie
timestamp: May 01, 2014, 02:55:32 pm
content: Please I need your support on how to sort out this problem.I am clocking Attiny4313 with an External Crystal Clock(7.3728MHz ).The USART of the Microcontroller is used to received data from the Computer through a USB port.I have on the Computer a Grahpic User Interface which has Buttons and Sliders.The buttons turn the Leds ON and OFF while the Sliders control Leds brightness.The ON and OFF of the Leds by the Buttons are working perfectly however I get error when using the Sliders to control the brightness.If I move the Slider slowly(one step at a time),everything works fine.However if I move the Slider very fast,then I get error.The error looks like this.If the Graphic User Interface shows say 70%,the Oscilloscope will show 13.2%,then if I move the Slider again slowly,the brightness(represented in percentage)on the Oscilloscope and the Grahpic Interface will be equal.If the Slider is moved very fast again,the error reappears.This time around the Graphic Interface can show say 50% but the oscilloscope will still show 13.2%.This 13.2% is what the oscilloscope always show whenever there is an error no matter what the Graphic User Interface shows(20%/40%/60%).My assumption is that the USART of the microcontroller is not fast enough to process the DATA it receives from the Computer.If this assumption is correct,then is it possible to solve this problem by replacing the 7.3728MHz crystal with a 16MHz crystal.I will highly appreciate your advice and idea in this regards.Once again thank you for the support.Firstoption

author: dannyf
author_rank: Super Contributor
timestamp: May 01, 2014, 03:35:30 pm
content: ".If this assumption is correct,then is it possible to solve this problem by replacing the 7.3728MHz crystal with a 16MHz crystal. "Yes, if your assumption is correct.There are limitless possibilities, slow oscillator is one of the unlikely causes, however.

author: scientist
author_rank: Frequent Contributor
timestamp: May 01, 2014, 07:00:52 pm
content: Why not have the GUI send data every .1 second so that you don't have the atmel decoding a rapidly changing input?

author: KD0RC
author_rank: Regular Contributor
timestamp: May 11, 2014, 02:40:31 pm
content: What baud rate are you using? This will affect the ability of your system to keep up with the data as well. I usually go with the fastest clock that my processor will support to make this kind of thing easier (mine are all one-off hobby projects, so component cost and count is not a big issue...). You do have to be aware of the relationship of clock speed with respect to the desired data rate. For example, on my current ATMega324 project, I have a 20.356250 MHz crystal to allow me to run 115Kbps. The odd frequency was chosen to minimize the serial clock error percentage at 115Kbps. I think that the calculator that I used for this is in ATMEL Studio, but it might have been something standalone - check AVRFreaks or the ATMEL site for how to do this.

author: MickM
author_rank: Regular Contributor
timestamp: May 18, 2014, 05:53:55 pm
content: HiTry a 14.7456 xtal.This is close to 16MHz, but better for baud rates.Here is wormfood's calculator:http://www.wormfood.net/avrbaudcalc.phpI am using an ATtiny4313-pu with 14.7456 xtal and 22pf xtal caps, works fine.Mick M.