Thanks janni and Filip,
Janni,the code in your link does not work for the 18F45K42 (the definition RX1DTPPS and RX2DTPPS are not declared according to the error messages). It seems to accept U1RXPPS =_RC7 U2RXPPS =_RD7. (Does not seem to work though)
Filip PPS_Mapping(_RC6, _OUTPUT, _TX1PPS) ' //RC6 PPS_Mapping(_RC7, _INPUT, _RX1) ' //RC7 Throws no error.
Neither works. I have tried to adapt the suggestions from here and loaded the revised mcl file given:
viewtopic.php?f=93&t=72327&p=291823&hil ... le#p291823
I am using EasyPic7 and portc 6 & 7 are mapped to the RS232 port, which appears as COM6 in the MB Usart terminal. Nothing is received. Tx does n ot seem to do anything either. With a scope on RA6, clock = 16MHz, so it seems that the clock is working at 64MHz.
Also I cannot debug with the EP7, ICD not supported in MikroProg for this MCU message is displayed. Is there a fix for this?
With the code below, 'UART1_Write_Text("Hello") 'throws error "incompatible type, c0mplex type to simple type". Individal chars seem to be accepted. (still does not work)
Code: Select all
Program UART
dim uart_rd as byte
Dim message as byte[5]
main:
OSCCON1 = 0x60
OSCFRQ = 0x08 '64MHZ
ANSELA = 0 ' let's keep life simple and make all digital
ANSELB = 0 ' all digital - Rx will not work if analogue
ANSELC = 0 ' all digital
ANSELD = 0 ' all digital
ANSELE = 0 ' all digital
TRISA = 0xff ' all input
TRISB = 0xff ' all input
TRISC = 0xff ' all input
TRISD = 0xff ' all input
TRISE = 0xff ' all input
Delay_ms(3000) ' give plenty of power-up settle time
'
' leave portC as default RX RC7, TX RC6
RC6PPS = 0 '
RC7PPS = 0
' need to remap to port d 6 & 7
'
PPS_Mapping(_RC6, _OUTPUT, _TX1PPS) ' //RC6
PPS_Mapping(_RC7, _INPUT, _RX1) ' //RC7
'
Lock_IOLOCK()
trisc = 0x80 'bit 7 is input (RX)
'trisd = 0x80
UART1_Remappable_Init(9600) ' Initialize UART module at 9600 bps
'UART2_Remappable_Init(9600)
Delay_ms(100)
UART_Set_Active(@UART1_Read, @UART1_Write, @UART1_Data_Ready, @UART1_Tx_Idle)
'UART_Set_Active(@UART2_Read, @UART2_Write, @UART2_Data_Ready, @UART2_Tx_Idle)
Uart1_Remappable_Write("H")
Uart1_Write("e")
Uart1_Write("l")
Uart1_Write("l")
Uart1_Write("o")
' UART1_Write_Text("Hello") 'throws error incompatible type
UART1_Write(13) ' Line Feed
UART1_Write(10) ' Carriage Return
while (TRUE) ' Endless loop
if (UART1_Data_Ready() <> 0) then ' If data is received,
uart_rd = UART1_Read() ' read the received data,
UART1_Write(uart_rd) ' and send data via UART
end if
wend
end.
Getting a bit lost here.
Any help woudl be appreciated as I am trying to replace a 18F45K22 and need to sort the UARTS out as we are using both UART1 and UART2.