Hi all,
I am starting to use the P24F PIC series (P24FJ64GA002) and my second try project gives me already a problem . In this project I try to make Uart1 send something. The main change for me is that the P24F has peripheral pin select registers, also for Uart1.
I think I have done everything well, but it does not work, I do not get a Uart TX signal on the TX pin chosen.
Here is the code.
I did check the contents of RPINR18 (for the selection of the Uart1 input pin), and RPOR7 (for the selection of the Uart output pin) and the values are OK. I do not know if the line "UART_Set_Active(..)" is necessary, but with or without it, it does not work.
Anyway, the led in the while true loop blinks at the correct frequency... , so I know the program is running.
Again I am conviced it is a stupid oversight error (as usual...) of me...
If anyone can help, thanks in advance!
Code: Select all
program Uart_Test;
{ Declarations section }
var Res: word;
begin
{ Main program }
//ADPCFG := 0xFFFF; // Configure AN pins as digital I/O
AD1PCFG := $ffff;
TrisA.0 := 0; //Led
LatA.0 := 0;
TrisB.15 := 0; // Uart output --> see post of jpc below
TrisB.14 := 1; // Uart input --> see post of jpc below
// Unlock_IOLOCK; --> see post of jpc below
Res := PPS_Mapping (14, _INPUT, _U1RX); // RP14 is uart1 input (pin 25)
Res := PPS_Mapping (15, _OUTPUT, _U1TX); // RP15 is uart1 output (pin 26)
// Lock_IOLOCK; --> see post of jpc below
Res := U1Mode; // for test purposes
Res := U1Sta; // for test purposes
Res := RPINR18; // for test purposes
Res := RPOR7; // for test purposes
Uart1_Init(9600);
Delay_ms(250);
UART_Set_Active(@UART1_Read, @UART1_Write, @UART1_Data_Ready, @UART1_Tx_Idle); // set UART1 active
Res := U1Mode; // for test purposes
Res := U1Sta; // for test purposes
Res := RPINR18; // for test purposes
Res := RPOR7; // for test purposes
while true do
begin
LatA.0 := 1; // Led
UART1_Write_Text('Test');
Uart1_Write(#13);
Uart1_Write(#10);
delay_ms(250);
LatA.0 := 0; // Led
delay_ms(250);
end;
end.
Here are the project settings (I use a 8Mhz crystal to have a 32 Mhz MCU clock):