[PIC] Crystal frequency selection

classic Classic list List threaded Threaded
22 messages Options
12
Reply | Threaded
Open this post in threaded view
|

[PIC] Crystal frequency selection

Neil
A bit academic, but this is bugging me... I was trying to get as close
to 115,200 baud on a PIC18F running at 64Mhz (or thereabouts).
At 64Mhz, best I can get is 0.8% error using SPBRG=34.
Calculating backwards, to get exactly 115,200, I can't find an "exact"
crystal.
Shouldn't I be able to find one of those "odd" values to get exactly
115,200 baud at around 64Mhz?

Cheers,
-Neil.

--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
Reply | Threaded
Open this post in threaded view
|

Re: [PIC] Crystal frequency selection

David VanHorn-2
115200 might be tough since the divisor is getting small.
7.372800 would work, 14.745600, and so on.


One thing a lot of people miss, which causes baud rates to be off, is
selecting the right crystal caps.
A crystal with CL of 22pF wants (2*CL-Cp) = 44pF - Cp where Cp is an
estimate of the parasitics (5 to 6 pf is a good first guess)
Running 22pF caps puts you a bit high, and the oscillator might not start
in all conditions.



On Tue, Oct 20, 2020 at 8:44 AM Neil <[hidden email]> wrote:

> A bit academic, but this is bugging me... I was trying to get as close
> to 115,200 baud on a PIC18F running at 64Mhz (or thereabouts).
> At 64Mhz, best I can get is 0.8% error using SPBRG=34.
> Calculating backwards, to get exactly 115,200, I can't find an "exact"
> crystal.
> Shouldn't I be able to find one of those "odd" values to get exactly
> 115,200 baud at around 64Mhz?
>
> Cheers,
> -Neil.
>
> --
> http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
> View/change your membership options at
> http://mailman.mit.edu/mailman/listinfo/piclist
>
--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
Reply | Threaded
Open this post in threaded view
|

Re: [PIC] Crystal frequency selection

David VanHorn-2
58.982400 is as close as you'll get to 64 MHz and still divide evenly.

You have 10 bits, and 5% error would be marginal, so I would shoot for >1%
error so as to give the other system more than half of the error budget.

An obscure little bug these days was in the Atmel Mega128 which had it's
low power mode as the default.  Without exactly the right crystal (very low
CL value) the oscillator amplitude would be low, and parts of the chip
would sometimes not get clocked. (!)   This led to baud rates being a
little slow and some non-deterministic execution, but it would occur so
infrequently that you would more think it was a bug.  The issue was
uncovered for us when another batch of chips simply wouldn't start the
crystal osc at all.  Setting the chip to high power crystal cured all
ills.  I know a number of M128 users hit this problem.


On Tue, Oct 20, 2020 at 8:50 AM David VanHorn <[hidden email]> wrote:

> 115200 might be tough since the divisor is getting small.
> 7.372800 would work, 14.745600, and so on.
>
>
> One thing a lot of people miss, which causes baud rates to be off, is
> selecting the right crystal caps.
> A crystal with CL of 22pF wants (2*CL-Cp) = 44pF - Cp where Cp is an
> estimate of the parasitics (5 to 6 pf is a good first guess)
> Running 22pF caps puts you a bit high, and the oscillator might not start
> in all conditions.
>
>
>
> On Tue, Oct 20, 2020 at 8:44 AM Neil <[hidden email]> wrote:
>
>> A bit academic, but this is bugging me... I was trying to get as close
>> to 115,200 baud on a PIC18F running at 64Mhz (or thereabouts).
>> At 64Mhz, best I can get is 0.8% error using SPBRG=34.
>> Calculating backwards, to get exactly 115,200, I can't find an "exact"
>> crystal.
>> Shouldn't I be able to find one of those "odd" values to get exactly
>> 115,200 baud at around 64Mhz?
>>
>> Cheers,
>> -Neil.
>>
>> --
>> http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
>> View/change your membership options at
>> http://mailman.mit.edu/mailman/listinfo/piclist
>>
>
--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
Reply | Threaded
Open this post in threaded view
|

Re: [PIC] Crystal frequency selection

John Lawton
In reply to this post by David VanHorn-2
Which device?

For the 18F25K22, -0.08% error at 64MHz clock according to the datasheet.

John

On 20/10/2020 15:50, David VanHorn wrote:

> 115200 might be tough since the divisor is getting small.
> 7.372800 would work, 14.745600, and so on.
>
>
> One thing a lot of people miss, which causes baud rates to be off, is
> selecting the right crystal caps.
> A crystal with CL of 22pF wants (2*CL-Cp) = 44pF - Cp where Cp is an
> estimate of the parasitics (5 to 6 pf is a good first guess)
> Running 22pF caps puts you a bit high, and the oscillator might not start
> in all conditions.
>
>
>
> On Tue, Oct 20, 2020 at 8:44 AM Neil <[hidden email]> wrote:
>
>> A bit academic, but this is bugging me... I was trying to get as close
>> to 115,200 baud on a PIC18F running at 64Mhz (or thereabouts).
>> At 64Mhz, best I can get is 0.8% error using SPBRG=34.
>> Calculating backwards, to get exactly 115,200, I can't find an "exact"
>> crystal.
>> Shouldn't I be able to find one of those "odd" values to get exactly
>> 115,200 baud at around 64Mhz?
>>
>> Cheers,
>> -Neil.
>>
>> --
>> http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
>> View/change your membership options at
>> http://mailman.mit.edu/mailman/listinfo/piclist
>>

--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
Reply | Threaded
Open this post in threaded view
|

Re: [PIC] Crystal frequency selection

David VanHorn-2
What divisor?  I get 555.55...

On Tue, Oct 20, 2020, 9:11 AM John Lawton <[hidden email]> wrote:

> Which device?
>
> For the 18F25K22, -0.08% error at 64MHz clock according to the datasheet.
>
> John
>
> On 20/10/2020 15:50, David VanHorn wrote:
> > 115200 might be tough since the divisor is getting small.
> > 7.372800 would work, 14.745600, and so on.
> >
> >
> > One thing a lot of people miss, which causes baud rates to be off, is
> > selecting the right crystal caps.
> > A crystal with CL of 22pF wants (2*CL-Cp) = 44pF - Cp where Cp is an
> > estimate of the parasitics (5 to 6 pf is a good first guess)
> > Running 22pF caps puts you a bit high, and the oscillator might not start
> > in all conditions.
> >
> >
> >
> > On Tue, Oct 20, 2020 at 8:44 AM Neil <[hidden email]> wrote:
> >
> >> A bit academic, but this is bugging me... I was trying to get as close
> >> to 115,200 baud on a PIC18F running at 64Mhz (or thereabouts).
> >> At 64Mhz, best I can get is 0.8% error using SPBRG=34.
> >> Calculating backwards, to get exactly 115,200, I can't find an "exact"
> >> crystal.
> >> Shouldn't I be able to find one of those "odd" values to get exactly
> >> 115,200 baud at around 64Mhz?
> >>
> >> Cheers,
> >> -Neil.
> >>
> >> --
> >> http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
> >> View/change your membership options at
> >> http://mailman.mit.edu/mailman/listinfo/piclist
> >>
>
> --
> http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
> View/change your membership options at
> http://mailman.mit.edu/mailman/listinfo/piclist
>
--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
Reply | Threaded
Open this post in threaded view
|

Re: [PIC] Crystal frequency selection

John Lawton
 From the datasheet DS41412F page 383:

SYNC = 0 BRGH = 1, or SYNC = 1, BRG16 = 1

Actual speed = 115.11k, error -0.08% SPBRGHx: SPBRGx (decimal) = 138

I should have said Fosc, (not clock speed) = 64MHz.

J

On 20/10/2020 16:18, David VanHorn wrote:

> What divisor?  I get 555.55...
>
> On Tue, Oct 20, 2020, 9:11 AM John Lawton <[hidden email]> wrote:
>
>> Which device?
>>
>> For the 18F25K22, -0.08% error at 64MHz clock according to the datasheet.
>>
>> John
>>
>> On 20/10/2020 15:50, David VanHorn wrote:
>>> 115200 might be tough since the divisor is getting small.
>>> 7.372800 would work, 14.745600, and so on.
>>>
>>>
>>> One thing a lot of people miss, which causes baud rates to be off, is
>>> selecting the right crystal caps.
>>> A crystal with CL of 22pF wants (2*CL-Cp) = 44pF - Cp where Cp is an
>>> estimate of the parasitics (5 to 6 pf is a good first guess)
>>> Running 22pF caps puts you a bit high, and the oscillator might not start
>>> in all conditions.
>>>
>>>
>>>
>>> On Tue, Oct 20, 2020 at 8:44 AM Neil <[hidden email]> wrote:
>>>
>>>> A bit academic, but this is bugging me... I was trying to get as close
>>>> to 115,200 baud on a PIC18F running at 64Mhz (or thereabouts).
>>>> At 64Mhz, best I can get is 0.8% error using SPBRG=34.
>>>> Calculating backwards, to get exactly 115,200, I can't find an "exact"
>>>> crystal.
>>>> Shouldn't I be able to find one of those "odd" values to get exactly
>>>> 115,200 baud at around 64Mhz?
>>>>
>>>> Cheers,
>>>> -Neil.
>>>>
>>>> --
>>>> http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
>>>> View/change your membership options at
>>>> http://mailman.mit.edu/mailman/listinfo/piclist
>>>>
>> --
>> http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
>> View/change your membership options at
>> http://mailman.mit.edu/mailman/listinfo/piclist
>>

--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
Reply | Threaded
Open this post in threaded view
|

Re: [PIC] Crystal frequency selection

David Van Horn
Well that's certainly close enough.

________________________________
From: [hidden email] <[hidden email]> on behalf of John Lawton <[hidden email]>
Sent: Tuesday, October 20, 2020 9:40 AM
To: [hidden email] <[hidden email]>
Subject: Re: [PIC] Crystal frequency selection

>From the datasheet DS41412F page 383:

SYNC = 0 BRGH = 1, or SYNC = 1, BRG16 = 1

Actual speed = 115.11k, error -0.08% SPBRGHx: SPBRGx (decimal) = 138

I should have said Fosc, (not clock speed) = 64MHz.

J

On 20/10/2020 16:18, David VanHorn wrote:

> What divisor?  I get 555.55...
>
> On Tue, Oct 20, 2020, 9:11 AM John Lawton <[hidden email]> wrote:
>
>> Which device?
>>
>> For the 18F25K22, -0.08% error at 64MHz clock according to the datasheet.
>>
>> John
>>
>> On 20/10/2020 15:50, David VanHorn wrote:
>>> 115200 might be tough since the divisor is getting small.
>>> 7.372800 would work, 14.745600, and so on.
>>>
>>>
>>> One thing a lot of people miss, which causes baud rates to be off, is
>>> selecting the right crystal caps.
>>> A crystal with CL of 22pF wants (2*CL-Cp) = 44pF - Cp where Cp is an
>>> estimate of the parasitics (5 to 6 pf is a good first guess)
>>> Running 22pF caps puts you a bit high, and the oscillator might not start
>>> in all conditions.
>>>
>>>
>>>
>>> On Tue, Oct 20, 2020 at 8:44 AM Neil <[hidden email]> wrote:
>>>
>>>> A bit academic, but this is bugging me... I was trying to get as close
>>>> to 115,200 baud on a PIC18F running at 64Mhz (or thereabouts).
>>>> At 64Mhz, best I can get is 0.8% error using SPBRG=34.
>>>> Calculating backwards, to get exactly 115,200, I can't find an "exact"
>>>> crystal.
>>>> Shouldn't I be able to find one of those "odd" values to get exactly
>>>> 115,200 baud at around 64Mhz?
>>>>
>>>> Cheers,
>>>> -Neil.
>>>>
>>>> --
>>>> http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
>>>> View/change your membership options at
>>>> http://mailman.mit.edu/mailman/listinfo/piclist
>>>>
>> --
>> http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
>> View/change your membership options at
>> http://mailman.mit.edu/mailman/listinfo/piclist
>>

--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
Reply | Threaded
Open this post in threaded view
|

Re: [PIC] Crystal frequency selection

Neil
In reply to this post by John Lawton
18F45Q10.  But I would expect that the EUSART is the same on both. I'll
check the datasheet.

But my point though is that isn't there a crystal that would for which
there is a SPBRG value that results in 0% error?




On 10/20/2020 11:10 AM, John Lawton wrote:

> Which device?
>
> For the 18F25K22, -0.08% error at 64MHz clock according to the datasheet.
>
> John
>
> On 20/10/2020 15:50, David VanHorn wrote:
>> 115200 might be tough since the divisor is getting small.
>> 7.372800 would work, 14.745600, and so on.
>>
>>
>> One thing a lot of people miss, which causes baud rates to be off, is
>> selecting the right crystal caps.
>> A crystal with CL of 22pF wants (2*CL-Cp) = 44pF - Cp where Cp is an
>> estimate of the parasitics (5 to 6 pf is a good first guess)
>> Running 22pF caps puts you a bit high, and the oscillator might not start
>> in all conditions.
>>
>>
>>
>> On Tue, Oct 20, 2020 at 8:44 AM Neil <[hidden email]> wrote:
>>
>>> A bit academic, but this is bugging me... I was trying to get as close
>>> to 115,200 baud on a PIC18F running at 64Mhz (or thereabouts).
>>> At 64Mhz, best I can get is 0.8% error using SPBRG=34.
>>> Calculating backwards, to get exactly 115,200, I can't find an "exact"
>>> crystal.
>>> Shouldn't I be able to find one of those "odd" values to get exactly
>>> 115,200 baud at around 64Mhz?
>>>
>>> Cheers,
>>> -Neil.
>>>
>>> --
>>> http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
>>> View/change your membership options at
>>> http://mailman.mit.edu/mailman/listinfo/piclist
>>>

--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
Reply | Threaded
Open this post in threaded view
|

Re: [PIC] Crystal frequency selection

Nicola Perotto
In reply to this post by Neil
Hi Neil & all,
I use the attached spreadsheet to calculate baud and errors.
Enter values in yellow cells.
       N


On 20/10/2020 16:42, Neil wrote:

> A bit academic, but this is bugging me... I was trying to get as close
> to 115,200 baud on a PIC18F running at 64Mhz (or thereabouts).
> At 64Mhz, best I can get is 0.8% error using SPBRG=34.
> Calculating backwards, to get exactly 115,200, I can't find an "exact"
> crystal.
> Shouldn't I be able to find one of those "odd" values to get exactly
> 115,200 baud at around 64Mhz?
>
> Cheers,
> -Neil.
>

--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

rs232.xls (20K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PIC] Crystal frequency selection

Neil
In reply to this post by John Lawton
I'm using datasheet 40001996D for the PIC18F45Q10.  The table of baud
rate formulas on page 515 continued into page 516, so I missed the
option with SYNC=1 and BRGH=1.  But same as the K22 part.  And yes I get
the 0.08% error now.

But still, shouldn't some easily available crystal value work out to 0%
error?

Cheers,
-Neil.




On 10/20/2020 11:40 AM, John Lawton wrote:

>   From the datasheet DS41412F page 383:
>
> SYNC = 0 BRGH = 1, or SYNC = 1, BRG16 = 1
>
> Actual speed = 115.11k, error -0.08% SPBRGHx: SPBRGx (decimal) = 138
>
> I should have said Fosc, (not clock speed) = 64MHz.
>
> J
>
> On 20/10/2020 16:18, David VanHorn wrote:
>> What divisor?  I get 555.55...
>>
>> On Tue, Oct 20, 2020, 9:11 AM John Lawton <[hidden email]> wrote:
>>
>>> Which device?
>>>
>>> For the 18F25K22, -0.08% error at 64MHz clock according to the datasheet.
>>>
>>> John
>>>
>>> On 20/10/2020 15:50, David VanHorn wrote:
>>>> 115200 might be tough since the divisor is getting small.
>>>> 7.372800 would work, 14.745600, and so on.
>>>>
>>>>
>>>> One thing a lot of people miss, which causes baud rates to be off, is
>>>> selecting the right crystal caps.
>>>> A crystal with CL of 22pF wants (2*CL-Cp) = 44pF - Cp where Cp is an
>>>> estimate of the parasitics (5 to 6 pf is a good first guess)
>>>> Running 22pF caps puts you a bit high, and the oscillator might not start
>>>> in all conditions.
>>>>
>>>>
>>>>
>>>> On Tue, Oct 20, 2020 at 8:44 AM Neil <[hidden email]> wrote:
>>>>
>>>>> A bit academic, but this is bugging me... I was trying to get as close
>>>>> to 115,200 baud on a PIC18F running at 64Mhz (or thereabouts).
>>>>> At 64Mhz, best I can get is 0.8% error using SPBRG=34.
>>>>> Calculating backwards, to get exactly 115,200, I can't find an "exact"
>>>>> crystal.
>>>>> Shouldn't I be able to find one of those "odd" values to get exactly
>>>>> 115,200 baud at around 64Mhz?
>>>>>
>>>>> Cheers,
>>>>> -Neil.
>>>>>
>>>>> --
>>>>> http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
>>>>> View/change your membership options at
>>>>> http://mailman.mit.edu/mailman/listinfo/piclist
>>>>>
>>> --
>>> http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
>>> View/change your membership options at
>>> http://mailman.mit.edu/mailman/listinfo/piclist
>>>

--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
Reply | Threaded
Open this post in threaded view
|

Re: [PIC] Crystal frequency selection

Neil
In reply to this post by Nicola Perotto
I had also created my own, but it's been trial-and-error (xtal freq and
SPBRG value) to find a spot-on crystal.
Now, if your spreadsheet runs through DIgikey's crystal frequency
selections and picks the spot-on option for me, then you have my
attention :)

Cheers,
-Neil.



On 10/20/2020 12:08 PM, Nicola Perotto wrote:

> Hi Neil & all,
> I use the attached spreadsheet to calculate baud and errors.
> Enter values in yellow cells.
>       N
>
>
> On 20/10/2020 16:42, Neil wrote:
>> A bit academic, but this is bugging me... I was trying to get as close
>> to 115,200 baud on a PIC18F running at 64Mhz (or thereabouts).
>> At 64Mhz, best I can get is 0.8% error using SPBRG=34.
>> Calculating backwards, to get exactly 115,200, I can't find an "exact"
>> crystal.
>> Shouldn't I be able to find one of those "odd" values to get exactly
>> 115,200 baud at around 64Mhz?
>>
>> Cheers,
>> -Neil.
>>
>
>
>

--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
Reply | Threaded
Open this post in threaded view
|

Re: [PIC] Crystal frequency selection

Neil
Okay, I found one... 14.7456Mhz crystal --> 59.9824Mhz Fosc, which is
close enough to 64Mhz.
Using SPBRG = 127 with that gives me spot-on 115,200 baud (so 0% error).
And there are 10+ suppliers for 3.2 x 2.5mm SMD crystals with that
frequency so that's common enough to be low-cost and not have to worry
about being discontinued in the near future.
Wish I didn't have to trial and error this though.

Cheers,
-Neil.





On 10/20/2020 12:27 PM, Neil wrote:

> I had also created my own, but it's been trial-and-error (xtal freq
> and SPBRG value) to find a spot-on crystal.
> Now, if your spreadsheet runs through DIgikey's crystal frequency
> selections and picks the spot-on option for me, then you have my
> attention :)
>
> Cheers,
> -Neil.
>
>
>
> On 10/20/2020 12:08 PM, Nicola Perotto wrote:
>> Hi Neil & all,
>> I use the attached spreadsheet to calculate baud and errors.
>> Enter values in yellow cells.
>>       N
>>
>>
>> On 20/10/2020 16:42, Neil wrote:
>>> A bit academic, but this is bugging me... I was trying to get as close
>>> to 115,200 baud on a PIC18F running at 64Mhz (or thereabouts).
>>> At 64Mhz, best I can get is 0.8% error using SPBRG=34.
>>> Calculating backwards, to get exactly 115,200, I can't find an "exact"
>>> crystal.
>>> Shouldn't I be able to find one of those "odd" values to get exactly
>>> 115,200 baud at around 64Mhz?
>>>
>>> Cheers,
>>> -Neil.
>>>
>>
>>
>>
>

--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
Reply | Threaded
Open this post in threaded view
|

Re: [PIC] Crystal frequency selection

John Lawton
But you didn't, it's all there is the datasheets :)

John

On 20/10/2020 17:34, Neil wrote:

> Okay, I found one... 14.7456Mhz crystal --> 59.9824Mhz Fosc, which is
> close enough to 64Mhz.
> Using SPBRG = 127 with that gives me spot-on 115,200 baud (so 0% error).
> And there are 10+ suppliers for 3.2 x 2.5mm SMD crystals with that
> frequency so that's common enough to be low-cost and not have to worry
> about being discontinued in the near future.
> Wish I didn't have to trial and error this though.
>
> Cheers,
> -Neil.
>
>
>
>
>
> On 10/20/2020 12:27 PM, Neil wrote:
>> I had also created my own, but it's been trial-and-error (xtal freq
>> and SPBRG value) to find a spot-on crystal.
>> Now, if your spreadsheet runs through DIgikey's crystal frequency
>> selections and picks the spot-on option for me, then you have my
>> attention :)
>>
>> Cheers,
>> -Neil.
>>
>>
>>
>> On 10/20/2020 12:08 PM, Nicola Perotto wrote:
>>> Hi Neil & all,
>>> I use the attached spreadsheet to calculate baud and errors.
>>> Enter values in yellow cells.
>>>        N
>>>
>>>
>>> On 20/10/2020 16:42, Neil wrote:
>>>> A bit academic, but this is bugging me... I was trying to get as close
>>>> to 115,200 baud on a PIC18F running at 64Mhz (or thereabouts).
>>>> At 64Mhz, best I can get is 0.8% error using SPBRG=34.
>>>> Calculating backwards, to get exactly 115,200, I can't find an "exact"
>>>> crystal.
>>>> Shouldn't I be able to find one of those "odd" values to get exactly
>>>> 115,200 baud at around 64Mhz?
>>>>
>>>> Cheers,
>>>> -Neil.
>>>>
>>>
>>>

--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
Reply | Threaded
Open this post in threaded view
|

Re: [PIC] Crystal frequency selection

Neil
The 14.7456 crystal?




On 10/20/2020 1:00 PM, John Lawton wrote:

> But you didn't, it's all there is the datasheets :)
>
> John
>
> On 20/10/2020 17:34, Neil wrote:
>> Okay, I found one... 14.7456Mhz crystal --> 59.9824Mhz Fosc, which is
>> close enough to 64Mhz.
>> Using SPBRG = 127 with that gives me spot-on 115,200 baud (so 0% error).
>> And there are 10+ suppliers for 3.2 x 2.5mm SMD crystals with that
>> frequency so that's common enough to be low-cost and not have to worry
>> about being discontinued in the near future.
>> Wish I didn't have to trial and error this though.
>>
>> Cheers,
>> -Neil.
>>
>>
>>
>>
>>
>> On 10/20/2020 12:27 PM, Neil wrote:
>>> I had also created my own, but it's been trial-and-error (xtal freq
>>> and SPBRG value) to find a spot-on crystal.
>>> Now, if your spreadsheet runs through DIgikey's crystal frequency
>>> selections and picks the spot-on option for me, then you have my
>>> attention :)
>>>
>>> Cheers,
>>> -Neil.
>>>
>>>
>>>
>>> On 10/20/2020 12:08 PM, Nicola Perotto wrote:
>>>> Hi Neil & all,
>>>> I use the attached spreadsheet to calculate baud and errors.
>>>> Enter values in yellow cells.
>>>>         N
>>>>
>>>>
>>>> On 20/10/2020 16:42, Neil wrote:
>>>>> A bit academic, but this is bugging me... I was trying to get as close
>>>>> to 115,200 baud on a PIC18F running at 64Mhz (or thereabouts).
>>>>> At 64Mhz, best I can get is 0.8% error using SPBRG=34.
>>>>> Calculating backwards, to get exactly 115,200, I can't find an "exact"
>>>>> crystal.
>>>>> Shouldn't I be able to find one of those "odd" values to get exactly
>>>>> 115,200 baud at around 64Mhz?
>>>>>
>>>>> Cheers,
>>>>> -Neil.
>>>>>
>>>>

--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
Reply | Threaded
Open this post in threaded view
|

Re: [PIC] Crystal frequency selection

Thomas Sefranek
In reply to this post by Neil

The real question is: why do you need an exact baud rate?Sent from my Verizon, Samsung Galaxy smartphone
-------- Original message --------From: Neil <[hidden email]> Date: 10/20/20  12:16 PM  (GMT-05:00) To: [hidden email] Subject: Re: [PIC] Crystal frequency selection I'm using datasheet 40001996D for the PIC18F45Q10.  The table of baud rate formulas on page 515 continued into page 516, so I missed the option with SYNC=1 and BRGH=1.  But same as the K22 part.  And yes I get the 0.08% error now.But still, shouldn't some easily available crystal value work out to 0% error?Cheers,-Neil.On 10/20/2020 11:40 AM, John Lawton wrote:>   From the datasheet DS41412F page 383:>> SYNC = 0 BRGH = 1, or SYNC = 1, BRG16 = 1>> Actual speed = 115.11k, error -0.08% SPBRGHx: SPBRGx (decimal) = 138>> I should have said Fosc, (not clock speed) = 64MHz.>> J>> On 20/10/2020 16:18, David VanHorn wrote:>> What divisor?  I get 555.55...>>>> On Tue, Oct 20, 2020, 9:11 AM John Lawton <[hidden email]> wrote:>>>>> Which device?>>>>>> For the 18F25K22, -0.08% error at 64MHz clock according to the datasheet.>>>>>> John>>>>>> On 20/10/2020 15:50, David VanHorn wrote:>>>> 115200 might be tough since the divisor is getting small.>>>> 7.372800 would work, 14.745600, and so on.>>>>>>>>>>>> One thing a lot of people miss, which causes baud rates to be off, is>>>> selecting the right crystal caps.>>>> A crystal with CL of 22pF wants (2*CL-Cp) = 44pF - Cp where Cp is an>>>> estimate of the parasitics (5 to 6 pf is a good first guess)>>>> Running 22pF caps puts you a bit high, and the oscillator might not start>>>> in all conditions.>>>>>>>>>>>>>>>> On Tue, Oct 20, 2020 at 8:44 AM Neil <[hidden email]> wrote:>>>>>>>>> A bit academic, but this is bugging me... I was trying to get as close>>>>> to 115,200 baud on a PIC18F running at 64Mhz (or thereabouts).>>>>> At 64Mhz, best I can get is 0.8% error using SPBRG=34.>>>>> Calculating backwards, to get exactly 115,200, I can't find an "exact">>>>> crystal.>>>>> Shouldn't I be able to find one of those "odd" values to get exactly>>>>> 115,200 baud at around 64Mhz?>>>>>>>>>> Cheers,>>>>> -Neil.>>>>>>>>>> -->>>>> http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive>>>>> View/change your membership options at>>>>> http://mailman.mit.edu/mailman/listinfo/piclist>>>>>>>> -->>> http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive>>> View/change your membership options at>>> http://mailman.mit.edu/mailman/listinfo/piclist>>>-- http://www.piclist.com/techref/piclist PIC/SX FAQ & list archiveView/change your membership options athttp://mailman.mit.edu/mailman/listinfo/piclist
--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
Reply | Threaded
Open this post in threaded view
|

Re: [PIC] Crystal frequency selection

Neil
As I mentioned at the opening, it was academic.




On 10/20/2020 1:29 PM, WA1RHP_Android wrote:
> The real question is: why do you need an exact baud rate?Sent from my Verizon, Samsung Galaxy smartphone
> -------- Original message --------From: Neil <[hidden email]> Date: 10/20/20  12:16 PM  (GMT-05:00) To: [hidden email] Subject: Re: [PIC] Crystal frequency selection I'm using datasheet 40001996D for the PIC18F45Q10.  The table of baud rate formulas on page 515 continued into page 516, so I missed the option with SYNC=1 and BRGH=1.  But same as the K22 part.  And yes I get the 0.08% error now.But still, shouldn't some easily available crystal value work out to 0% error?Cheers,-Neil.On 10/20/2020 11:40 AM, John Lawton wrote:>   From the datasheet DS41412F page 383:>> SYNC = 0 BRGH = 1, or SYNC = 1, BRG16 = 1>> Actual speed = 115.11k, error -0.08% SPBRGHx: SPBRGx (decimal) = 138>> I should have said Fosc, (not clock speed) = 64MHz.>> J>> On 20/10/2020 16:18, David VanHorn wrote:>> What divisor?  I get 555.55...>>>> On Tue, Oct 20, 2020, 9:11 AM John Lawton <[hidden email]> wrote:>>>>> Which device?>>>>>> For the 18F25K22, -0.08% error at 64MHz clock according to th!
 e datasheet.>>>>>> John>>>>>> On 20/10/2020 15:50, David VanHorn wrote:>>>> 115200 might be tough since the divisor is getting small.>>>> 7.372800 would work, 14.745600, and so on.>>>>>>>>>>>> One thing a lot of people miss, which causes baud rates to be off, is>>>> selecting the right crystal caps.>>>> A crystal with CL of 22pF wants (2*CL-Cp) = 44pF - Cp where Cp is an>>>> estimate of the parasitics (5 to 6 pf is a good first guess)>>>> Running 22pF caps puts you a bit high, and the oscillator might not start>>>> in all conditions.>>>>>>>>>>>>>>>> On Tue, Oct 20, 2020 at 8:44 AM Neil <[hidden email]> wrote:>>>>>>>>> A bit academic, but this is bugging me... I was trying to get as close>>>>> to 115,200 baud on a PIC18F running at 64Mhz (or thereabouts).>>>>> At 64Mhz, best I can get is 0.8% error using SPBRG=34.>>>>> Calculating backwards, to get exactly 115,200, I can't find an "exact">>>>> crystal.>>>>> Shouldn't I be able to find one of those "odd" values to get e!
 xactly>>>>> 115,200 baud at around 64Mhz?>>>>>>>>>> Cheers,>>>>> -Neil.>>>>>>>>>> -->>>>> http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive>>>>> View/change your membership options at>>>>> http://mailman.mit.edu/mailman/listinfo/piclist>>>>>>>> -->>> http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive>>> View/change your membership options at>>> http://mailman.mit.edu/mailman/listinfo/piclist>>>-- http://www.piclist.com/techref/piclist PIC/SX FAQ & list archiveView/change your membership options athttp://mailman.mit.edu/mailman/listinfo/piclist



--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
Reply | Threaded
Open this post in threaded view
|

Re: [PIC] Crystal frequency selection

John Lawton
In reply to this post by Neil
Well not that specifically, but the datasheet mentioned:

3.6864MHz, 11.0592MHz, 18.432MHz for 0% error @ 115.2kBaud

J



On 20/10/2020 18:11, Neil wrote:

> The 14.7456 crystal?
>
>
>
>
> On 10/20/2020 1:00 PM, John Lawton wrote:
>> But you didn't, it's all there is the datasheets :)
>>
>> John
>>
>> On 20/10/2020 17:34, Neil wrote:
>>> Okay, I found one... 14.7456Mhz crystal --> 59.9824Mhz Fosc, which is
>>> close enough to 64Mhz.
>>> Using SPBRG = 127 with that gives me spot-on 115,200 baud (so 0% error).
>>> And there are 10+ suppliers for 3.2 x 2.5mm SMD crystals with that
>>> frequency so that's common enough to be low-cost and not have to worry
>>> about being discontinued in the near future.
>>> Wish I didn't have to trial and error this though.
>>>
>>> Cheers,
>>> -Neil.
>>>
>>>
>>>
>>>
>>>
>>> On 10/20/2020 12:27 PM, Neil wrote:
>>>> I had also created my own, but it's been trial-and-error (xtal freq
>>>> and SPBRG value) to find a spot-on crystal.
>>>> Now, if your spreadsheet runs through DIgikey's crystal frequency
>>>> selections and picks the spot-on option for me, then you have my
>>>> attention :)
>>>>
>>>> Cheers,
>>>> -Neil.
>>>>
>>>>
>>>>
>>>> On 10/20/2020 12:08 PM, Nicola Perotto wrote:
>>>>> Hi Neil & all,
>>>>> I use the attached spreadsheet to calculate baud and errors.
>>>>> Enter values in yellow cells.
>>>>>          N
>>>>>
>>>>>
>>>>> On 20/10/2020 16:42, Neil wrote:
>>>>>> A bit academic, but this is bugging me... I was trying to get as close
>>>>>> to 115,200 baud on a PIC18F running at 64Mhz (or thereabouts).
>>>>>> At 64Mhz, best I can get is 0.8% error using SPBRG=34.
>>>>>> Calculating backwards, to get exactly 115,200, I can't find an "exact"
>>>>>> crystal.
>>>>>> Shouldn't I be able to find one of those "odd" values to get exactly
>>>>>> 115,200 baud at around 64Mhz?
>>>>>>
>>>>>> Cheers,
>>>>>> -Neil.
>>>>>>

--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
Reply | Threaded
Open this post in threaded view
|

Re: [PIC] Crystal frequency selection

Nicola Perotto
In reply to this post by Neil
I don't understand...
1) 0% error doesn't exists, never!
2) crystals have error...
You have to maintain the error in a KNOWN, acceptable range!
       N

PS: with a "round" crystal it's simpler to calculate timings :-)


On 20/10/2020 18:34, Neil wrote:

> Okay, I found one... 14.7456Mhz crystal --> 59.9824Mhz Fosc, which is
> close enough to 64Mhz.
> Using SPBRG = 127 with that gives me spot-on 115,200 baud (so 0% error).
> And there are 10+ suppliers for 3.2 x 2.5mm SMD crystals with that
> frequency so that's common enough to be low-cost and not have to worry
> about being discontinued in the near future.
> Wish I didn't have to trial and error this though.
>
> Cheers,
> -Neil.
>
>
>
>
>
> On 10/20/2020 12:27 PM, Neil wrote:
>> I had also created my own, but it's been trial-and-error (xtal freq
>> and SPBRG value) to find a spot-on crystal.
>> Now, if your spreadsheet runs through DIgikey's crystal frequency
>> selections and picks the spot-on option for me, then you have my
>> attention :)
>>
>> Cheers,
>> -Neil.
>>
>>
>>
>> On 10/20/2020 12:08 PM, Nicola Perotto wrote:
>>> Hi Neil & all,
>>> I use the attached spreadsheet to calculate baud and errors.
>>> Enter values in yellow cells.
>>>        N
>>>
>>>
>>> On 20/10/2020 16:42, Neil wrote:
>>>> A bit academic, but this is bugging me... I was trying to get as close
>>>> to 115,200 baud on a PIC18F running at 64Mhz (or thereabouts).
>>>> At 64Mhz, best I can get is 0.8% error using SPBRG=34.
>>>> Calculating backwards, to get exactly 115,200, I can't find an "exact"
>>>> crystal.
>>>> Shouldn't I be able to find one of those "odd" values to get exactly
>>>> 115,200 baud at around 64Mhz?
>>>>
>>>> Cheers,
>>>> -Neil.
>>>>
>>>
>>>

--

Nicola Perotto - NP Engineering
Sistemi Informatici ed Elettronici
skype: nicolap
mob IT: +39 335 7162 582
mob HU: +36 30 417 3780
tel: +39 06 916 502 732
fax: +39 0439 633 1191

--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
Reply | Threaded
Open this post in threaded view
|

Re: [PIC] Crystal frequency selection

David VanHorn-2
Errors have consequences. Poor designers will assume most or all the error
budget is theirs to spend.   In one application I am required to hold +/-
80 hz on transmit and an earlier design was typically 30 hz off. My design
using correct crystal caps is 3 hz off. Receivers in this application
benefit greatly from having the narrowest possible bandwidth.  Which
transmitter would you bet your life on?  You don't get to know the
bandwidth or frequency error of the other recievers..

On Tue, Oct 20, 2020, 12:06 PM Nicola Perotto <[hidden email]>
wrote:

> I don't understand...
> 1) 0% error doesn't exists, never!
> 2) crystals have error...
> You have to maintain the error in a KNOWN, acceptable range!
>        N
>
> PS: with a "round" crystal it's simpler to calculate timings :-)
>
>
> On 20/10/2020 18:34, Neil wrote:
> > Okay, I found one... 14.7456Mhz crystal --> 59.9824Mhz Fosc, which is
> > close enough to 64Mhz.
> > Using SPBRG = 127 with that gives me spot-on 115,200 baud (so 0% error).
> > And there are 10+ suppliers for 3.2 x 2.5mm SMD crystals with that
> > frequency so that's common enough to be low-cost and not have to worry
> > about being discontinued in the near future.
> > Wish I didn't have to trial and error this though.
> >
> > Cheers,
> > -Neil.
> >
> >
> >
> >
> >
> > On 10/20/2020 12:27 PM, Neil wrote:
> >> I had also created my own, but it's been trial-and-error (xtal freq
> >> and SPBRG value) to find a spot-on crystal.
> >> Now, if your spreadsheet runs through DIgikey's crystal frequency
> >> selections and picks the spot-on option for me, then you have my
> >> attention :)
> >>
> >> Cheers,
> >> -Neil.
> >>
> >>
> >>
> >> On 10/20/2020 12:08 PM, Nicola Perotto wrote:
> >>> Hi Neil & all,
> >>> I use the attached spreadsheet to calculate baud and errors.
> >>> Enter values in yellow cells.
> >>>        N
> >>>
> >>>
> >>> On 20/10/2020 16:42, Neil wrote:
> >>>> A bit academic, but this is bugging me... I was trying to get as close
> >>>> to 115,200 baud on a PIC18F running at 64Mhz (or thereabouts).
> >>>> At 64Mhz, best I can get is 0.8% error using SPBRG=34.
> >>>> Calculating backwards, to get exactly 115,200, I can't find an "exact"
> >>>> crystal.
> >>>> Shouldn't I be able to find one of those "odd" values to get exactly
> >>>> 115,200 baud at around 64Mhz?
> >>>>
> >>>> Cheers,
> >>>> -Neil.
> >>>>
> >>>
> >>>
>
> --
>
> Nicola Perotto - NP Engineering
> Sistemi Informatici ed Elettronici
> skype: nicolap
> mob IT: +39 335 7162 582
> mob HU: +36 30 417 3780
> tel: +39 06 916 502 732
> fax: +39 0439 633 1191
>
> --
> http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
> View/change your membership options at
> http://mailman.mit.edu/mailman/listinfo/piclist
>
--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
Reply | Threaded
Open this post in threaded view
|

Re: [PIC] Crystal frequency selection

John Lawton
In reply to this post by Nicola Perotto
0% error is always assuming the crystal frequency is as stated.

John



On 20/10/2020 19:04, Nicola Perotto wrote:

> I don't understand...
> 1) 0% error doesn't exists, never!
> 2) crystals have error...
> You have to maintain the error in a KNOWN, acceptable range!
>         N
>
> PS: with a "round" crystal it's simpler to calculate timings :-)
>
>
> On 20/10/2020 18:34, Neil wrote:
>> Okay, I found one... 14.7456Mhz crystal --> 59.9824Mhz Fosc, which is
>> close enough to 64Mhz.
>> Using SPBRG = 127 with that gives me spot-on 115,200 baud (so 0% error).
>> And there are 10+ suppliers for 3.2 x 2.5mm SMD crystals with that
>> frequency so that's common enough to be low-cost and not have to worry
>> about being discontinued in the near future.
>> Wish I didn't have to trial and error this though.
>>
>> Cheers,
>> -Neil.
>>
>>
>>
>>
>>
>> On 10/20/2020 12:27 PM, Neil wrote:
>>> I had also created my own, but it's been trial-and-error (xtal freq
>>> and SPBRG value) to find a spot-on crystal.
>>> Now, if your spreadsheet runs through DIgikey's crystal frequency
>>> selections and picks the spot-on option for me, then you have my
>>> attention :)
>>>
>>> Cheers,
>>> -Neil.
>>>
>>>
>>>
>>> On 10/20/2020 12:08 PM, Nicola Perotto wrote:
>>>> Hi Neil & all,
>>>> I use the attached spreadsheet to calculate baud and errors.
>>>> Enter values in yellow cells.
>>>>         N
>>>>
>>>>
>>>> On 20/10/2020 16:42, Neil wrote:
>>>>> A bit academic, but this is bugging me... I was trying to get as close
>>>>> to 115,200 baud on a PIC18F running at 64Mhz (or thereabouts).
>>>>> At 64Mhz, best I can get is 0.8% error using SPBRG=34.
>>>>> Calculating backwards, to get exactly 115,200, I can't find an "exact"
>>>>> crystal.
>>>>> Shouldn't I be able to find one of those "odd" values to get exactly
>>>>> 115,200 baud at around 64Mhz?
>>>>>
>>>>> Cheers,
>>>>> -Neil.
>>>>>
>>>>

--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
12