Thota Suresh Avionics
Member level 2
- Joined
- Jul 15, 2013
- Messages
- 45
- Helped
- 2
- Reputation
- 4
- Reaction score
- 2
- Trophy points
- 8
- Activity points
- 345
PIC24EP512GP806,MPLAB8.8
I trying to work with PIC24 modules and for my first attempt I tried to print on uart.
I cannot print any thing , not even garbage values.
After PLL I need to get oscilator as 240Mhz
I used Fin = 20mhz oscillator
M = 46+2 = 48
N1 = 0+2 = 2
N2 = (0+1) *2 = 2
Fosc = Fin * (M/(N1+N2)) = 20000000 * (48/(2+2)) = 240M
BRGH = 0; so, U1BRG = 3124
nothing is printed in UART !
If I does the same, up to 160Mhz(fosc) i.e, M = 30 + 2 = 32
corresponding U1BRG = 2082 it is working fine. Any higher M values than 30 that it is not printing any thing in hyper terminal.
will there be any limit or where am I doing wrong ??
I trying to work with PIC24 modules and for my first attempt I tried to print on uart.
I cannot print any thing , not even garbage values.
After PLL I need to get oscilator as 240Mhz
I used Fin = 20mhz oscillator
M = 46+2 = 48
N1 = 0+2 = 2
N2 = (0+1) *2 = 2
Fosc = Fin * (M/(N1+N2)) = 20000000 * (48/(2+2)) = 240M
BRGH = 0; so, U1BRG = 3124
nothing is printed in UART !
If I does the same, up to 160Mhz(fosc) i.e, M = 30 + 2 = 32
corresponding U1BRG = 2082 it is working fine. Any higher M values than 30 that it is not printing any thing in hyper terminal.
will there be any limit or where am I doing wrong ??
Code:
#include"main.h"
#include"uart.h"
_FGS(GSS_OFF & GWRP_OFF & GSSK_OFF)
_FOSCSEL(FNOSC_PRI & IESO_OFF)
_FOSC(POSCMD_XT & OSCIOFNC_OFF & FCKSM_CSECMD)
_FWDT(WDTPRE_PR32 & PLLKEN_ON & WINDIS_OFF & FWDTEN_OFF)
_FAS(AWRP_OFF & APL_OFF & APLK_OFF);
_FICD(ICS_PGD3 & RSTPRI_PF & JTAGEN_OFF)
int main()
{
Config_Clock();
Config_UART();
Init_UART();
while(1);
return 0;
}
void Config_Clock(void)
{
PLLFBD = 46; // M = PLLDIV+2
CLKDIVbits.PLLPOST = 0; // N2 = (PLLPOST+1)*2
CLKDIVbits.PLLPRE = 0; // N1 = PLLPRE+2
__builtin_write_OSCCONH( 0x03 ); // Initiate Clock Switch to
__builtin_write_OSCCONL( OSCCON || 0x01 ); // Start clock switching
while( OSCCONbits.COSC != 0b011 );
// Wait for Clock switch to occur
while( OSCCONbits.LOCK != 1 );
}
void Config_UART(void)
{
// PPS
// Unlock Registers
__builtin_write_OSCCONL(OSCCON & 0xbf);
RPINR18bits.U1RXR = 66; //Configure Input Functions , Assign U1RX To Pin RP30 UART1 working
RPOR0bits.RP65R = 1; //Configure Output Functions , Assign U1TX To Pin RP16
__builtin_write_OSCCONL(OSCCON | 0x40);
}
void Init_UART(void)
{
U1BRG = 3124;//1561;
U1MODE = 0x8008; // BRGH = 0;
U1STA = 0x0400; //UTXEN = 1;
printf("UART Ready\n");
}
Last edited: