Tahmid
Advanced Member level 6
- Joined
- Jun 17, 2008
- Messages
- 4,764
- Helped
- 1,799
- Reputation
- 3,590
- Reaction score
- 1,662
- Trophy points
- 1,413
- Location
- Berkeley, California
- Activity points
- 30,713
Hi,
As you can see from the diagram, the 4MHz is in the input to the system and the output from the system is 48MHz (when postscaler is set to 1:2). So, you can no longer use the 4MHz clock. Now it is 48MHz.
Hope this helps.
Tahmid.
adc_result = (ADRESH<<2) + (ADRESL>>6);
What you wrote is also okay. But the problem is, you set PR2 to 255. So, you can't assign the ADC value directly to CCPR1L as CCPR1L is an 8-bit register.
CCP1CONbits.DC1B0 |= 0;
CCP1CONbits.DC1B1 |= 0;
what is the difference of using '+' with the | operator in this case?adc_result = (ADRESH<<2) + (ADRESL>>6);
why I cannot set PR2 with 255? I think that would be the lowest frequency if the value is 255 according to the formula. right?What you wrote is also okay. But the problem is, you set PR2 to 255.
but to enable the PLL is during setting of configuration bits right??
adc_result = (ADRESL>>6) | ((unsigned int)(ADRESH<<8));
adc_result = ((unsigned int)(ADRESH<<8)) | (ADRESL>>6);
ADRESH << 8
ADRESH << 2
DC1B0 and DC1B1 are used to set decimal places, eg for setting 220.50 in CCPR1L. The max is still 255. The 2 other bits are for precision. I have to look this up and I'll tell you more about it.
Yea. You also have to set the PLL prescaler and the postscaler. If you check the diagram you posted in the last page, you can configure the system clock by using the prescaler and postscaler.
Hi,
Like I said before the 10-bit works like this:
8 bits for 0 to 255, 2 bits for decimal places.
So, you can't get 0 to 1023.
Hope this helps.
Tahmid.
If I will leave as it is the default PLL prescaller would be /1 and also the prescaller is 1/2... so I still I can get the 48Mhz clock I want...right?
i think its the same if we say
for the left justified setting
adc_result = (ADRESL>>6) | ((unsigned int)(ADRESH<<8));
with
adc_result = ((unsigned int)(ADRESH<<8)) | (ADRESL>>6);
Yes, you will get the 48MHz clock.
---------- Post added at 23:20 ---------- Previous post was at 23:19 ----------
Maybe you might not need it, but you might want to read through AN594 [Using the CCP Module(s)] for revision:
https://ww1.microchip.com/downloads/en/AppNotes/00594B.PDF
0b1111111100 | 0b11 = 0b1111111111
Actually there is something very wrong with the forum and it is behaving very strangely, doesn't show users , doesn't show new messages and what happened to you happened to me yesterday..with one of my messages.
Your post is a single one shown three times (mine was shown two times), if I try to delete any of them they will all be deleted, they have a single post identity code.
x = adc_read()>> 2;
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?