I am Trying to configure UART MODULE for 9600 Baud rate in dsPIC33EP512GM710 and here is my Code i am just trying to send a char to be monitored in serial port in the PC
my code for calculating the baud rate
Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#define _XTAL_FREQ 10000000#define FP 40000000#define BAUDRATE 9600#define BRGVAL ((FP/BAUDRATE)/16)-1////clock settings
PLLFBD =30;// M=32
CLKDIVbits.PLLPOST=0;// N1=2
CLKDIVbits.PLLPRE=0;// N2=2
OSCTUN =0;// Tune FRC oscillator, if FRC is used// Initiate Clock Switch to Primary Oscillator with PLL (NOSC=0b011)
__builtin_write_OSCCONH(0x03);
__builtin_write_OSCCONL(OSCCON |0x01);// Wait for Clock switch to occurwhile(OSCCONbits.COSC!=0b011);// Wait for PLL to lockwhile(OSCCONbits.LOCK!=1);
my code for configuring the PLL and clock i am trying to calculate the same for 40Mhz operation with an external crystal of 10 Mhz
You have only shown us the oscillator configuration code and none of the UART initialisation.
You have also told us nothing about what is going wrong - what is not working but you expect it should?
By the way, given a 10MHz crystal, you will get an Fosc of 80MHz, not 40MHz as you say. Your WILL get 40MIPS but that is not the same thing. However, you are actually saved by the fact that the UART uses Fosc/2 which will be 40MHz for this particular chip.
Susan