News:

Let's find out together what makes a PIC Tick!

Main Menu

Uart settings for 18F87K90

Started by Dave-S, Today at 11:38 AM

Previous topic - Next topic

Dave-S

Uart settings for 18F87K90

Trying to set HSerOut/HSerIn on a 18F87K90 so as to send AT commands to a WizFi380 wifi unit.
I have it working ok on a 18F47K40 using Uart2,
Device = 18F47K40
Declare Xtal = 64
Declare Hserial2_Baud = 115200 'Set the Baud rate for USART1
Declare HRSOut2_Pin  = PORTD.6 'Set the pin used for USART1 TX
Declare HRSIn2_Pin   = PORTD.7 'Set the pin used for USART1 RX
Declare Hserial2_RCSTA = %10010000 'Enable serial port and continuous receive
Declare Hserial2_Clear = On 'Enable Error clearing on received characters      ' Clear the buffer before receiving
 TRISD.6 = 0
 TRISD.7 = 1
I need to use a larger I/O pin pic so installed it onto a 18F87K90 but cannot get the UART1 to work,
Device = 18F87K90
Declare Xtal = 64
OSCCON = %11111100    'for 64
OSCTUNE = %11000000 'PLL on
Declare Hserial1_Baud = 9600   '115200    ' Set the Baud rate for USART1
Declare HSerOut1_Pin  = PORTC.6        ' Set the pin used for USART1 TX
Declare HSerIn1_Pin   = PORTC.7
Declare Hserial1_RCSTA = %10010000   ' Enable serial port and continuous receive
Declare Hserial1_TXSTA = %10101100 'enable transmit and asynchronous mode
Declare Hserial2_Clear = On
BAUDCON1 = %00001000
Declare Access_Upper_64K = True
TRISC.6 = 0
TRISC.7 = 1
Tried setting the Hserial1_RCSTA, Hserial1_TXSTA and BAUDCON1 but cannot get it to send, it appears that HSerOut1 is not functioning.  Using a serial terminal on PC HSerIn1 receives data but sending data using HSerOut1 i get nothing.

Obviously my settings are not correct and need some help. I did try using Uart2, PORTG1/PORTG2.

Any help Appreciated.
Thanks David