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.

[PIC] PIC18F46J50 Problem UART2

Status
Not open for further replies.

sponiche

Newbie level 1
Joined
Jun 6, 2009
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,289
Hello,
I need help.

PIC USED 18F46J50
Compiler MikroC PRO

Set RX2 and TX2 in the RP0 RP1.
Puertos TX1 and RX1 occupied.
code used
Code:
{
    RCSTA2.SPEN=1; // activate USART2
    TRISA.F0=1;	   //RX2 Input
    TRISA.F1=0;	   //TX2 Output

    INTCON.GIE=0;  // disable interrupts    EECON2=0X55;   //
    EECON2=0XAA;
    PPSCON.IOLOCK=0;// Allows you to change pin

    RPINR16=0X00;   //RX2 em RP0
    RPOR1=0X05;	    //TX2 em RP1

    EECON2=0X55;
    EECON2=0XAA;
    PPSCON.IOLOCK=1;// closes mapping
    INTCON.GIE=1;   // enable interrupts
	.
	.
	.
	.
	.
UART2_Init(9600);
}


Problem - Error when starting the UART2, will the mapping is done well?
Lack set any records?
other code that has been tried:
Code:
{	Unlock_IOLOCK();
    	PPS_Mapping_NoLock(0, _INPUT, _RX2_DT2);  // RX - RP0.
    	PPS_Mapping_NoLock(1, _OUTPUT, _TX2_CK2); // TX - RP1.
    	Lock_IOLOCK();
}
the problem is the same.

someone can help me with this problem?
thank
 
Last edited by a moderator:

I suggest that you do not try to unlock and lock the PPS registers until you have everything else working correctly.
The unprogrammed default is to have the IOL1WAY bit set in the config registers which means that you can only unlock the registers once - once you lock them then you cannot unlock them again (until a power cycle) even if you do use the correct unlock sequence.
However the power-on default for the IOLOCK bit is to have the PPS registers unlocked. Therefore you can set them however you need to without the need to do the unlock sequence - just DON'T lock them again afterwards.
In your first code snippet, you are trying to use C to perform the unlock and lock sequences. This may or may not work depending on how the compiler generates the instructions. The unlock sequence must be performed as sequential instructions as given with no intervening code. This is why the macros (that you use in the 2nd snippet) are provided by the compiler.
Susan
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top