Em 25/09/2012 09:20, Michael Rigby-Jones escreveu: > On 9/25/2012 1:48 AM, Lee Mulvogue wrote: >> >> I'd always read in the past to not use the internal OSC of a PIC as=20 >> it was too innacurate, but am now wondering if this is still the case=20 >> for a PIC24F? >> >> I've just started making a board based on a PIC24FJ64GA004 (my first=20 >> time with a 24F), and added the usual 20MHz crystal and supporting=20 >> caps; but are the modern PICs accurate enough to start considering=20 >> dumping this external setup? The most time sensitive thing I'm doing=20 >> is interrupting @ 16kHz for PCM sound playback (current sample to PWM=20 >> output, set flag for Main loop to process the next sample), and simple >> RS232 comms. The datasheet seems to indicate a max variation of +/-=20 >> 5%, but I don't have a benchmark to compare that against. >> >> I'd possibly be running the 8Mhz internal with the 4x PLL multiplier,=20 >> resulting in 16MIPS, vs the 10MIPS of the external 20MHz crystal=20 >> without PLL. >> >> Thoughts? >> >> Lee > -----Original Message----- > From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu] On Behalf = Of Joe Wronski > Sent: 25 September 2012 12:56 > To: Microcontroller discussion list - Public. > Subject: Re: [PIC] PIC24F; dump external OSC? > >>> Check the requirements of the RS232. You might want to consider the ca= se >>> where one unit is running at +5% and the other at -5% (if both ends are= the >>> same unit). The baud rate accuracy requirement increases with baud rat= e, >>> IIRC. Also, your PWM frequency will be affected, so, the pitch of you= r >>> sound may vary. The answer is in the requirements, not the opinions of >>> people who don't have the numbers. >>> >>> >>> Joe W > Baud rate accuracy requirements (as a percentage) is independent of the a= ctual baud rate. An inaccurate baud generator clock will have the same eff= ect at 300 baud as 115200 baud. > > 5% is already far too much and equates to half a bit slip over a 10bit wo= rd (8,N,1) which will be threshold at which the comms simply can not work. = Reliability problems are likely to occur before you reach 5%, and I would w= ant no more than about 3% total error including sending and receiving ends,= obviously the lower the better. > > Mike The UART samples near the middle of the bit time plus up to 1/4 or 1/16 of a bit time, depending on the oversampling configuration. So, the first bit can be sampled at up to 75% of its duration for 4x oversampling and 56.25% for 16x oversampling. There are 8 more bits to be sampled (including the stop bit). Assuming an oversampling of 4x, you have only 25% of a bit time of margin. That gives a maximum error of 3.125% but you must remember that the other end probably have some imprecision too, so divide the error by two. UARTS usually use a majority of three samples near the middle of the bit time, what improves things a little. ASCII Art (fixed pitch font): Start-bit detected at its very beginning: ------------+ +-------------------+ | | | +-------------------+ +--- ^ ^ ^ ^ | | | | | | | | | | | <- sampling points | | | | (4x oversampling) start bit first bit detected here sampled here Start-bit late detect: ------------+ +-------------------+ | | | +-------------------+ +--- ^ ^ ^ ^ | | | | | | | | | | | <- sampling points | | | | (4x oversampling) start bit first bit detected here sampled here As you can see, as soon as the samples start to happen late, the third sample will be out of the bit cell. If the middle sample also falls outside of the bit cell you will get a sampling error. Isaac --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .