comm port RB1 is not read on 16F1847

General discussion on mikroPascal PRO for PIC.
Post Reply
Author
Message
GWL
Posts: 13
Joined: 04 May 2014 05:25

comm port RB1 is not read on 16F1847

#1 Post by GWL » 20 Oct 2022 05:24

Hi,
I noticed that in the selection of supported micro controllers for the EasyPIC V7 that the 16F1847 is now supported. I wrote a simple rs232 loop program and employed the Mikroe UART terminal program to send a data stream.
The EasyPIC v7 was set for a 18 pin device.

The program (below) compiled (ver 7.6.0) but would not program the chip. EasyPIC v7 version the lastest v2.11.

I then placed the 16F1847 into the PICflash and programmed it with a mikroProg. This programmed the device. The chip is then placed back into the easyPIC for testing.

The program sets RB1 for rx and RB2 for tx.

On initalisation 'hello world' is sent to the terminal.
The terminal transmits '123456' which is verified to be at RB1 with a CRO.
The software does not read the rx port.

Can someone please point out what I have done wrong.

thanks

greg

program test16F1847rs232;
{ compiler : 7.6.0

programmers :
- easyPic V7 or
- mikroProg for PIC with PICflash

application:
- toggle led on power up
- write hello world to RS232
- echo received rs232

controller : 16F1847 at 32 MHz
}

const
PortOut = 0;
portIn = 1;

onn = 1;
off = 0;

var
uart_rd : byte;

led : sbit at LATA2_bit; led_direction : sbit at TRISA2_bit;
rxB : sbit at LATB1_bit; b1_direction : sbit at TRISB1_bit;
txB : sbit at LATB2_bit; b2_direction : sbit at TRISB2_bit;

procedure toggleLed;
begin
led := onn;
delay_ms(500);

led := off;
delay_ms(500);

led := onn;
delay_ms(500);
end;


begin
osccon := %11110000; // internal 8Mhz with 4x PPL for a 32Mhz clk
ADCON0 := %00000000; // disable analog functions

C1ON_bit := 0; // Disable comparators
C2ON_bit := 0;
CCP1CON := 0;
CCP2CON := 0;


APFCON0 := %01100000 ; // RX on RB1 SDO1 onRA6 SS1 on RA5 pin selection registers
APFCON1 := %00000000 ; // TX on RB2

b1_direction := portIn; // pin 7 RB1
b2_direction := portOut; // pin 8 RB2

led_direction := portOut; // pin 1 RA2

toggleLed; // RA2 on off on

UART1_Init(9600);
Delay_ms(100);

Uart1_Write_Text('hello world');

while true do
begin
if (UART1_Data_Ready() <> 0) then
begin
uart_rd := UART1_Read();
Uart1_Write(uart_rd);
end;
end;

end.

Post Reply

Return to “mikroPascal PRO for PIC General”