Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Serial not working - Peripheral Pin Select

Status
Not open for further replies.

Timmymna

New Member
Hi,
I am modifying a **broken link removed** but need use of the PMP so I'm having to do a bit of rewiring, mainly moving the UART pins from RP8 & 9 but this is where I'm running into problems.

I can get the PIC to transmit to the PC but the PIC won't respond to anything from the PC. I am using the sample code which is a serial repeater, thing works fine but when I switch to RP2 & 3 it doesn't reply.

Original code
Code:
	RPINR18bits.U1RXR = 9;		// Make Pin RP9 U1RX
	RPOR4bits.RP8R = 3;		// Make Pin RP8 U1TX

	PADCFG1 = 0xFF;			// Make analog pins digital 

	LATB = 0x0;
	TRISB = 0x0FFF;			// Configure LED pins as output

	TMR1 = 0;			// Clear timer 1
	PR1 = 0x3D09;			// Interrupt every 250ms
	IFS0bits.T1IF = 0;		// Clear interrupt flag
	IEC0bits.T1IE = 1;		// Set interrupt enable bit
	T1CON = 0x8030;			// Fosc/4, 1:256 prescale, start TMR1

	TRISB = 0x0300;

	U1BRG  = BRGVAL;
	U1MODE = 0x8000; 		// Reset UART to 8-n-1, alt pins, and enable 
	U1STA  = 0x0440; 		// Reset status register and enable TX & RX
	_U1RXIF=0;			// Clear UART RX Interrupt Flag

Modified code
Code:
	RPINR18bits.U1RXR = 3;		// Make Pin RP3 U1RX
	RPOR1bits.RP2R = 3;		// Make Pin RP2 U1TX

	PADCFG1 = 0xFF;			// Make analog pins digital 

	LATB = 0x0;
	TRISB = 0x0FFF;			// Configure LED pins as output

	TMR1 = 0;			// Clear timer 1
	PR1 = 0x3D09;			// Interrupt every 250ms
	IFS0bits.T1IF = 0;		// Clear interrupt flag
	IEC0bits.T1IE = 1;		// Set interrupt enable bit
	T1CON = 0x8030;			// Fosc/4, 1:256 prescale, start TMR1

	TRISB = 0x000C;

	U1BRG  = BRGVAL;
	U1MODE = 0x8000; 		// Reset UART to 8-n-1, alt pins, and enable 
	U1STA  = 0x0440; 		// Reset status register and enable TX & RX
	_U1RXIF=0;			// Clear UART RX Interrupt Flag

This is the first time using the 24F series and the microchip compiler so I might be making an obvious mistake but I can't see anything.

Thanks
 
I forgot to mention, I have removed switch 2 and I'm just wiring the TX/RX pins to the ones I want on the PIC, testing the PIC pins with a logic analyser. The PIC will transmit but when the RX pin is connected, the PIC is pulling the pin low.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top