internal osc for pic18f4550

Status
Not open for further replies.

SimonM

New Member
Hi,

I have a concern and a problem using the internal osc for pic18f4550. I am trying to do a rs-232 connexion on my pc (the hardware is in place...max 232 etc..) and I am bugging at finding the osc speed using this configuration: #pragma config FOSC = INTOSCIO_EC. I need to assign a value to BRG, but I couldn't find a concrete value for the FOSC.

Furthermore, in my initial schematic design, I planned on using a external oscillator, but I am currently working without it. Do you think it is a good idea to have a external oscillator? I know that 18f4550 were designed to get a much more stable internal clock.

here is the current code I have:

#pragma config WDT = OFF //Disable watchdog timer
#pragma config LVP=OFF
#pragma config FOSC = INTOSCIO_EC




#include <p18f4550.h>
#include <delays.h>
#include <usart.h>
#include <stdio.h>
#include <stdlib.h>



void portConfig(void);
void relaysInit(void);
void eusartConfig(void);

void main(void)
{
portConfig();
relaysInit();

TXSTA = 0b00100100;
RCSTA = 0b10010000;
BAUDCON = 0b01000000;
SPBRG = 42; // probly faulty value!

bankEnable();
bankAToggle();

while (1)
{
//Write data
TXREG='B';
}
}


Simon
 
Last edited:
Thanks, I have been twinking with my program this morning and both CPU loopback and PIC loopback works. I tried the full communication path and I think that my baud rate isn't properly set or the baud result isn't good because I don't receive anything at the desired baud rate. However, if I lower my baud rate there is something showing that is completely useless. According to the datasheet, I should be @ 8mhz with a baud rate of 9600 -> SPBRG = 12.

Both communication doesn't work for now. I can't send nor receive from both sides.

Got any idea about what is going on?

EDIT: found the solution.

1) by default the internal clock is set at 1MHz .... I needed to edit the osccon value so that it run @8MHz

Thanks for the help everybody
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…