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
}
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.
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.
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.
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.