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.

[SOLVED] PIC24FV UART Configuration issue

Status
Not open for further replies.

vijitron

Newbie level 6
Joined
Feb 22, 2009
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,366
Hi
I am facing issues in UART communication, PIC24FV32KA302 .

i configured the UART for 9600 baud rate, but unfortunately i am receiving junk values in the terminal.
I suspected the OSC configuration, but i don't really know weather i did configured right way for 8Mhz.
below is what i did,


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#define FOSC    80000000L
#define FCY    (FOSC/2)
#define BAUD_RATE_UART1    9600L
 
 
//Configuration bits
 
 
   _FBS(BSS_OFF & BWRP_OFF)
    _FGS(GSS0_OFF & GWRP_OFF)
    _FOSCSEL(FNOSC_FRCDIV & IESO_OFF)
    _FOSC(FCKSM_CSECMD & POSCFREQ_MS & OSCIOFNC_ON & POSCMOD_NONE & SOSCSEL_SOSCLP)
    _FWDT(FWDTEN_OFF & WINDIS_OFF & FWPSA_PR128 & WDTPS_PS32768)
    _FPOR(MCLRE_ON & BORV_LPBOR & BOREN_BOR3 & I2C1SEL_PRI & PWRTEN_OFF)
    _FICD( ICS_PGx3)
    _FDS(DSWDTEN_OFF & DSBOREN_ON &  DSWDTOSC_SOSC & DSWDTPS_DSWDTPSF) //DSWDT SOSC = LPRC
 
 
//Osc config,
  CLKDIVbits.RCDIV=0;
  CLKDIVbits.DOZEN=0;
 
//Uart Config
 
 
   U1MODE = 0; // Clear UART1 mode register
    U1STA = 0;    // Clear UART1 status register
    U1BRG = (FCY/(16*BAUD_RATE_UART1))-1; // Calculate value of baud rate register
    U1MODEbits.UARTEN = 1;   // Enable UART1 module
    U1STAbits.UTXEN = 1;     // Enable UART1 transmit



Please let me know how to correct this problem.
 
Last edited by a moderator:

Code:
#define FOSC 80000000L
I guess, you are the first one who received a PIC 24 with 80 MHz internal oscillator!
 

Code:
#define FOSC 80000000L
I guess, you are the first one who received a PIC 24 with 80 MHz internal oscillator!

Omg:-o, its my mistake. Thank you for noting that. Now its working.
When using printf , some characters missing at terminal.
So i wrote my own Putstr function verifying the while(! TRMT)

Now its working fine.

Thanks again
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top