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.

Pic24 to lora communication using uart

Status
Not open for further replies.

user19

Junior Member level 2
Joined
Apr 7, 2017
Messages
22
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
209
Hi,

I have to communicate between PIC24FJ64GA006 and LORA module using UART .In the UART code to communicate between PIC and PC ,do I have to do the initialisation setting for LORA or else can I use the UART code as itself ?

Could someone please give suggestions on this?


Thanks
 

Hi ,

I am using the uart code shown below to connect between PIC24FJ64GA006 and LORA(RN2903) transmitting the command "sys get ver" to get the device version .Probing the transmitter pin of LORA , we are getting the command .But in the receiver pin , we are getting "err" when the LORA module is reset for any command given.

Is this because of some mistake in the code that it is not getting transmitted properly.

Could anyone please suggest some method to overcome this?

Code:
void Init_UART(void)
 {
	U1MODEbits.UARTEN = 0;	// Bit15 TX, RX DISABLED, ENABLE at end of func
	U1MODEbits.USIDL = 0;	// Bit13 Continue in Idle
	U1MODEbits.IREN = 0;	// Bit12 No IR translation
	U1MODEbits.RTSMD = 1;	// Bit11 Simplex Mode
	U1MODEbits.UEN = 0;		// Bits8,9 TX,RX enabled, CTS,RTS not
	U1MODEbits.WAKE = 0;	// Bit7 No Wake up (since we don't sleep here)
	U1MODEbits.LPBACK = 0;	// Bit6 No Loop Back
	U1MODEbits.ABAUD = 0;	// Bit5 No Autobaud (would require sending '55')
	U1MODEbits.RXINV = 0;	// Bit4 IdleState = 1
	U1MODEbits.BRGH = 0;	// Bit3 16 clocks per bit period
	U1MODEbits.PDSEL = 0;	// Bits1,2 8bit, No Parity
	U1MODEbits.STSEL = 0;	// Bit0 One Stop Bit
	
	//U1BRG = BAUDRATEREG1;	// baud rate
    U1BRG = BRGVAL;
	// Load all values in for U1STA SFR
	U1STAbits.UTXISEL1 = 0;	//Bit15 Int when Char is transferred (1/2 config!)
	U1STAbits.UTXINV = 0;	//Bit14 N/A, IRDA config
	U1STAbits.UTXISEL0 = 0;	//Bit13 Other half of Bit15
	U1STAbits.UTXBRK = 0;	//Bit11 Disabled
	U1STAbits.UTXEN = 0;	//Bit10 TX pins controlled by periph
	U1STAbits.UTXBF = 0;	//Bit9 *Read Only Bit*
	U1STAbits.TRMT = 0;		//Bit8 *Read Only bit*
	U1STAbits.URXISEL = 0;	//Bits6,7 Int. on character recieved
	U1STAbits.ADDEN = 0;	//Bit5 Address Detect Disabled
	U1STAbits.RIDLE = 0;	//Bit4 *Read Only Bit*
	U1STAbits.PERR = 0;		//Bit3 *Read Only Bit*
	U1STAbits.FERR = 0;		//Bit2 *Read Only Bit*
	U1STAbits.OERR = 0;		//Bit1 *Read Only Bit*
	U1STAbits.URXDA = 0;	//Bit0 *Read Only Bit*

	IFS0bits.U1TXIF = 0;	// Clear the Transmit Interrupt Flag
	IEC0bits.U1TXIE = 0;	// Enable Transmit Interrupts
	IFS0bits.U1RXIF = 0;	// Clear the Recieve Interrupt Flag
	IEC0bits.U1RXIE = 0;	// Enable Recieve Interrupts

	U1MODEbits.UARTEN = 1;	// And turn the peripheral on

	U1STAbits.UTXEN = 1;
 }

void InitClock() {
     CLKDIVbits.RCDIV=0;
    while(OSCCONbits.LOCK != 1) {};
 }

int main(void)
{
    unsigned char WORD[] = "sys get ver";
    Init_UART();
    InitClock();
        while(1)
    {
        PrintStringUART1(WORD);
        WriteCharToUART1(10);
        WriteCharToUART1(13);

        }
        
    return 0;
}


Thanks
 

Have you tested the UART Communication. Is UART Working fine ? Only after you get UART working test communication with Lora. I have ordered Lora Click from mikroElektronika. I will get it in 4 days. I will do further testing with it and answer for your Lora related questions.
 

Hi Okada,

I have tested UART connection between PIC and PC and it is working fine. But when tested with LORA module it is giving "err" message at the receiver pin.


Thanks
 

Hi ,

Could anyone please help me with this issue .


Thanks and Regards
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top