I'm trying to migrate a code i have for PIC 18F47Q10 to PIC 18F47Q43. I manage to make all needed updates (mostly declare different names for PPS and CLC's) and code is compiled without errors, but for some reason the hw UART port doesn't seem to work (i got no response to either output or input).
This is the code i use, regarding USART setup, for PIC 18F47Q10 which works ok:
#chip 18F47q10, 64
#option explicit
#startup InitPPS, 85
#define PPSToolPart 18f47q10
function
#define USART2_BAUD_RATE 115200
#define BUFFER_SIZE 2900
#define USART2_DELAY 0 ms
#define USART2_BLOCKING
Sub InitPPS
UNLOCKPPS
RX2PPS = 0x0009 'RB1 > RX2
RB2PPS = 0x000B 'TX2 > RB2
LOCKPPS
End Sub
On Interrupt UsartRX2Ready Call readUSART
And this is the modified code for PIC 18F47Q43:
#chip 18F47q43, 64
#option explicit
#startup InitPPS, 85
#define PPSToolPart 18f47q43
function
#define USART2_BAUD_RATE 115200
#define BUFFER_SIZE 2900
#define USART2_DELAY 0 ms
#define USART2_BLOCKING
Sub InitPPS
UNLOCKPPS
RB2PPS = 0x0023 // TX2 > RB2
U2RXPPS = 0x0009 // RB1 > RX2
LOCKPPS
End Sub
On Interrupt UART2ReceiveInterrupt Call readUSART
For the conversion i used PPS and CLC Designer tools, and for the name of the Interrupt routine (to place received byte into a ring buffer) i consulted the 18F47Q43.dat file in gcbasic\chipdata folder.
And this is the ASM code i got for INITUSART function, for PIC 18F47Q10:
The PPS and the ASM all looks correct. I was comparing here to MPLAB.
So do the following. Do the basic work ?
Remove the interrupt. Use a simple get data send data. Does that work ?
#chip 18F47q43, 64
#option explicit
#startup InitPPS, 85
#define PPSToolPart 18f47q43
#define USART2_BAUD_RATE 115200
#define USART2_DELAY OFF
#define USART2_BLOCKING
Sub InitPPS
UNLOCKPPS
// PPS is correct.
RB2PPS = 0x0023 // TX2 > RB2
U2RXPPS = 0x0009 // RB1 > RX2
LOCKPPS
End Sub
// Not really needed but for testing
Comport = 2
Do
If USART2HasData Then
// Send the RX to the TX
HserPrint HSerReceiveFrom(2), 2
End If
Loop
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The PPS and the ASM all looks correct. I was comparing here to MPLAB.
So do the following. Do the basic work ?
Remove the interrupt. Use a simple get data send data. Does that work ?
#chip 18F47q43, 64
#option explicit
#startup InitPPS, 85
#define PPSToolPart 18f47q43
#define USART2_BAUD_RATE 115200
#define USART2_DELAY OFF
#define USART2_BLOCKING
Sub InitPPS
UNLOCKPPS
// PPS is correct.
RB2PPS = 0x0023 // TX2 > RB2
U2RXPPS = 0x0009 // RB1 > RX2
LOCKPPS
End Sub
// Not really needed but for testing
Comport = 2
Do
If USART2HasData Then
// Send the RX to the TX
HserPrint HSerReceiveFrom(2), 2
End If
Loop
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I connect the board with PIC to an amstrad cpc. Using a usb2serial cable (which is verified that works ok) i tried this code instead:
RESTART:IfUSART2HasDataThendata_buf=HSerReceive2// Send the RX to the TXhsersenddata_buf,2wait500ms;HserPrintHSerReceiveFrom(2),2EndIfgotorestart
The good news is that whenever i send a character to the Amstrad (e.g. PIC's usart port), i get a respond back, BUT not with the character i sent, instead i always get ÿÿ characters as respond to PC terminal...
Exactly the same behavior i got whe i use HserPrint HSerReceiveFrom(2), 2 instead of hsersend data_buf,2.
port speed is set to 115200bps at both ends, and it's the only speed in terminal that i get a respond, so most probable baud rate is correctly set.
Does this give any clue?
Last edit: ikonsgr74 11 hours ago
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I just try the above code but without the wait. I try to send many characters and USART responds back with the same number of characters, but again are completely irrelevant and not the same every time! For example:
I sent 3 times '12345' and i got in response:
¿ÿ÷¿
o»÷÷
ßû¿
Even when i send i single same char i got a different respond each time, for example i sent 3 times '2' and got:
÷
¿
ÿ
Last edit: ikonsgr74 11 hours ago
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm trying to migrate a code i have for PIC 18F47Q10 to PIC 18F47Q43. I manage to make all needed updates (mostly declare different names for PPS and CLC's) and code is compiled without errors, but for some reason the hw UART port doesn't seem to work (i got no response to either output or input).
This is the code i use, regarding USART setup, for PIC 18F47Q10 which works ok:
And this is the modified code for PIC 18F47Q43:
For the conversion i used PPS and CLC Designer tools, and for the name of the Interrupt routine (to place received byte into a ring buffer) i consulted the 18F47Q43.dat file in gcbasic\chipdata folder.
And this is the ASM code i got for INITUSART function, for PIC 18F47Q10:
And for PIC 18F47Q43:
Last edit: ikonsgr74 13 hours ago
The PPS and the ASM all looks correct. I was comparing here to MPLAB.
So do the following. Do the basic work ?
Remove the interrupt. Use a simple get data send data. Does that work ?
The PPS and the ASM all looks correct. I was comparing here to MPLAB.
So do the following. Do the basic work ?
Remove the interrupt. Use a simple get data send data. Does that work ?
I connect the board with PIC to an amstrad cpc. Using a usb2serial cable (which is verified that works ok) i tried this code instead:
The good news is that whenever i send a character to the Amstrad (e.g. PIC's usart port), i get a respond back, BUT not with the character i sent, instead i always get ÿÿ characters as respond to PC terminal...
Exactly the same behavior i got whe i use HserPrint HSerReceiveFrom(2), 2 instead of hsersend data_buf,2.
port speed is set to 115200bps at both ends, and it's the only speed in terminal that i get a respond, so most probable baud rate is correctly set.
Does this give any clue?
Last edit: ikonsgr74 11 hours ago
I just try the above code but without the wait. I try to send many characters and USART responds back with the same number of characters, but again are completely irrelevant and not the same every time! For example:
I sent 3 times '12345' and i got in response:
¿ÿ÷¿
o»÷÷
ßû¿
Even when i send i single same char i got a different respond each time, for example i sent 3 times '2' and got:
÷
¿
ÿ
Last edit: ikonsgr74 11 hours ago
Baud Rate calcs.
MPLAB 64Mhz at 115k
~~~
// BRGL 138;
U2BRGL = 0x8A;
;U2BRGH=SPBRGH_TEMP2
banksel U2BRGH
clrf U2BRGH,BANKED = 0
;U2BRGL=SPBRGL_TEMP2
movlw 137
movwf U2BRGL,BANKED = 137
chip 18F47q43, 64
option explicit
~~~
YES! That worked straight!
Ok.
Isolate the issue by removing the special init. Leave the do-loop. Does the standard init work?