Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] mikro PIC18F4620 UART recv PLL bug!

Status
Not open for further replies.

Alloy

Advanced Member level 4
Joined
Apr 3, 2016
Messages
116
Helped
0
Reputation
0
Reaction score
0
Trophy points
16
Activity points
1,003
Hey
I tried to send UART commands from Arduino to PIC18F4620.
It did not work at any baud rates, pic received garbage, only 'x' characters.

But then I realized that my PIC is using HS oscillator with 4X PLL.
And I tried this code:
Code:
// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(2400);
}

// the loop routine runs over and over again forever:
void loop() {
  Serial.println("Aaa");
  delay(100);        // delay in between reads for stability
}
and on pic:
Code:
     UART1_Init(600);
       
        while(1)
        {
           if (1 && UART1_Data_Ready() == 1) {
            /// UART_Read_Text(tmp, "\n", 64)     ;
            tmp[0] = UART1_Read();
            tmp[1] = 0;
            My_Print(tmp);
       }

and it received "A", 'a', and some garbage, but works way better than my other ideas.

What's wrong?
 

Show us the config settings and the oscillator initialisation code as you MUST get the oscillator set up correctly before anything else.
Also what frequency crystal are you using?
Susan
 

Show us the config settings and the oscillator initialisation code as you MUST get the oscillator set up correctly before anything else.
Also what frequency crystal are you using?
Susan

I think I have already figured this out.
I am using 8MHz crystal, but mikroC expects me to enter "320000" value in the text field.
I mean, it expects me to enter value after PLL (8 * 4 = 32).

I'm not sure if it's a bug or the feature, but for me it seems just stupid, I was always sure that I am supposed to type the PCB crystal frequency in the textbox.
 

Hi,

I am using 8MHz crystal, but mikroC expects me to enter "320000" value in the text field.
I mean, it expects me to enter value after PLL (8 * 4 = 32).

8M = 8,000,000
8M x 4 = 32,000,000, not 320,000 --> there are two "0" missing.

Klaus
 

No, You have to enter 32 MHz in the MCU Clock Frequency text box. It is not Crystal frequency text box. *MHz Crystal freq * 4x PLL = 32 MHz. If you use USB in the PIC18F4550 then you have to enter Clock as 48 MHz.
 

8M = 8,000,000
8M x 4 = 32,000,000, not 320,000 --> there are two "0" missing.
Klaus

Sorry, just a typo in my post, I had it typed correctly in the mikroC.


No, You have to enter 32 MHz in the MCU Clock Frequency text box. It is not Crystal frequency text box. *MHz Crystal freq * 4x PLL = 32 MHz. If you use USB in the PIC18F4550 then you have to enter Clock as 48 MHz.

Why 48MHz and not 32MHz?
 

48 MHz is for PIC18F4550 if you are using USB in it. For your PIC it is 8 MHz * 4x PLL = 32 MHz. It is the MCU Clock Frequency and not Crystal Frequency.

FOSC is different. MCU Clock of 32 MHz gets divided by 4 and FOSC will be 32 MHz / 4 = 8 MHz.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top