# HSEROUT intermittent working OSHONSOFT

#### camerart

Joined Feb 25, 2013
2,767
Hi,
Can someone put this CODE into their simulator please, and test for the HSEROUT.

I have programs, where it is intermittently working, does anyone know why?
Camerart
Code:
'18F46K20 8MHz XTL LED TEST
Define CONFIG1L = 0x00
Define CONFIG1H = 0x08  '2  'XTL   8  'INT OSC
Define CONFIG2L = 0x0c
Define CONFIG2H = 0x20
Define CONFIG3L = 0x04
Define CONFIG3H = 0x80
Define CONFIG4L = 0x00  'Set for HVP
Define CONFIG4H = 0x00
Define CONFIG5L = 0x0f
Define CONFIG5H = 0xc0
Define CONFIG6L = 0x0f
Define CONFIG6H = 0xe0
Define CONFIG7L = 0x0f
Define CONFIG7H = 0x40

Define CLOCK_FREQUENCY = 8
OSCCON = %01110010  'internal 8Mhz clock
Define SINGLE_DECIMAL_PLACES = 2

Define SIMULATION_WAITMS_VALUE = 1  'Comment in for SIM out for PIC

Hseropen 9600  'does a basic config of TX and RX including BAUDCON, SPEN, CREN, TXEN etc.

TRISB = %00000000
TRISC = %00000000
TRISD = %00000000

Symbol yled = PORTE.1
Symbol rled = PORTE.2

'START:
yled = 1
rled = 1
WaitMs 1000
yled = 0
rled = 0
WaitMs 1000

loop:

Hserout "TEST", CrLf
Toggle rled
Toggle yled
WaitMs 1000

Goto loop
End

#### ericgibbs

Joined Jan 29, 2010
14,207
hi,
This is the same problem as you posted for recently.
Did Vlad do a fix.?

Forever loops in the Bit test..
E

#### camerart

Joined Feb 25, 2013
2,767
hi,
This is the same problem as you posted for recently.
Did Vlad do a fix.?

Forever loops in the Bit test..
E
View attachment 241043
Morning E,
Vlad replied, and said he he's behind with this, so I'm a bit stuck.

I'm concentrationg on FUNCTIONS at the moment, so I don't remember anything. I've got a vague recollection about the Breakpoints manager.

The HSEROUT doesn't work at the early part of the program, but somehow does where I need it, so I've got to use it as it is
Thanks, C.

#### camerart

Joined Feb 25, 2013
2,767
hi,
This is the same problem as you posted for recently.
Did Vlad do a fix.?

Forever loops in the Bit test..
E
View attachment 241043
Hi again E,
Am I correct that I can use SEROUT instead, and is this programmed not using Oshonsoft?
(As you can see I'm still confused about HW, SW)

EDIT: I've got it to show TEST here:
C

#### Attachments

• 51.7 KB Views: 2
Last edited:

#### ericgibbs

Joined Jan 29, 2010
14,207
hi,
This clip is from the manual.
E

#### Attachments

• 1.7 KB Views: 5

#### camerart

Joined Feb 25, 2013
2,767
hi,
This clip is from the manual.
E
Hi E,
[On all supported PICs], in other words this won't work either!
What do you suggest? Vlad may be years getting round to fixing my PIC.
C

#### ericgibbs

Joined Jan 29, 2010
14,207
hi C,
As before, you could try a block of ASM: code in the Basic program.

Have you actually tried the Serial examples in a dummy program for the 'K' version PIC??

Example 1:
Define SEROUT_DELAYUS = 5000
Serout PORTC.6, 1200, "Hello world!", CrLf

Example 2:
Dim i As Byte
loop:
Serin PORTC.7, 9600, i
Serout PORTC.6, 9600, "Number: ", #i, CrLf
Goto loop

E

#### camerart

Joined Feb 25, 2013
2,767
hi C,
As before, you could try a block of ASM: code in the Basic program.

Have you actually tried the Serial examples in a dummy program for the 'K' version PIC??

Example 1:
Define SEROUT_DELAYUS = 5000
Serout PORTC.6, 1200, "Hello world!", CrLf

Example 2:
Dim i As Byte
loop:
Serin PORTC.7, 9600, i
Serout PORTC.6, 9600, "Number: ", #i, CrLf
Goto loop

E
Hi E,
It looks like I have to learn a bit of ASM.

I posted a TEST image #4, so that works, but not a LOOP as you suggest.
C

#### ericgibbs

Joined Jan 29, 2010
14,207
hi,
Tried it, works, but very Slooooow.

E

#### ericgibbs

Joined Jan 29, 2010
14,207
hi,
I have managed to reduce that Define SEROUT_DELAYUS = 5000 , to 50 , recompile after changing it.

The Serial input accepts only one charcater at a time.!!

E

#### camerart

Joined Feb 25, 2013
2,767
hi,
I have managed to reduce that Define SEROUT_DELAYUS = 5000 , to 50 , recompile after changing it.

The Serial input accepts only one charcater at a time.!!

E
Hi E,
I tried it LIVE and mine goes to a computer terminal via radio. I can hear it each LOOP.

[Serout PORTC.6, 9600, "TEST2", CrLf]

Here is a terminal view:
C

#### Attachments

• 47.3 KB Views: 4

#### camerart

Joined Feb 25, 2013
2,767
Hi,
I'm not sure what I did, but serout2 test program is working. I'll try a bit farther.
C

#### Attachments

• 50.5 KB Views: 6

#### ericgibbs

Joined Jan 29, 2010
14,207
hi C,
I expect you know that the compiler will create the correct machine code for the Hserout, but it is the OSH IDE program that is unable to emulate/simulate the PIC's hardware serial port.

I would suggest you test your compiled programs in an actual 'test bed' PIC 'K' , they should work OK.

I have run some tests in the IDE.

The IDE loads the TX buffer as shown in the PIC image, but the IDE does not output the serial data to the serial ports.

Its upto Vlad to upgrade the IDE

E

#### camerart

Joined Feb 25, 2013
2,767
hi C,
I expect you know that the compiler will create the correct machine code for the Hserout, but it is the OSH IDE program that is unable to emulate/simulate the PIC's hardware serial port.

I would suggest you test your compiled programs in an actual 'test bed' PIC 'K' , they should work OK.

I have run some tests in the IDE.

The IDE loads the TX buffer as shown in the PIC image, but the IDE does not output the serial data to the serial ports.

Its upto Vlad to upgrade the IDE

E
Hi E,
I'm not sure what this means: "'test bed' PIC 'K'", but I've been compiling the programs, and onto the 18F46K20 PIC. It seems a bit precarious, as sometimes the SEROUT works on the OSH system, and sometimes 'live' , the problem could be my programming? At the moment, I have the PIC working, so I'll carry on, until it stops, or gets difficult.

I contacted Vlad, asking him if he could give an indication, of when he may fix this.
C.

#### camerart

Joined Feb 25, 2013
2,767
hi C,
I expect you know that the compiler will create the correct machine code for the Hserout, but it is the OSH IDE program that is unable to emulate/simulate the PIC's hardware serial port.

I would suggest you test your compiled programs in an actual 'test bed' PIC 'K' , they should work OK.

I have run some tests in the IDE.

The IDE loads the TX buffer as shown in the PIC image, but the IDE does not output the serial data to the serial ports.

Its upto Vlad to upgrade the IDE

E
Hi again E,
I can't use the simulator for most tests, as I'm READing 'live' peripherals.
C

#### ericgibbs

Joined Jan 29, 2010
14,207
Mornig C,
This is the title of your thread. 'HSEROUT intermittent working OSHONSOFT'

It helps if you specify which feature you have a problem with, ie: IDE, Hardware or Software etc..
In post #12, the listing must be via a PC port from some external device, so if the program is viable you will get the print out.

As I said, the OSH compiler appears to be creating the full/correct machine Code for the 'K' PIC, BUT the IDE does not simulate that hardware feature.

Have you tried the ASM Code that the OSH creates in MPLAB.??
You need to add/modify the OSH ASM Header to keep the MPLAB happy.

E

#### camerart

Joined Feb 25, 2013
2,767
Mornig C,
This is the title of your thread. 'HSEROUT intermittent working OSHONSOFT'

It helps if you specify which feature you have a problem with, ie: IDE, Hardware or Software etc..
In post #12, the listing must be via a PC port from some external device, so if the program is viable you will get the print out.

As I said, the OSH compiler appears to be creating the full/correct machine Code for the 'K' PIC, BUT the IDE does not simulate that hardware feature.

Have you tried the ASM Code that the OSH creates in MPLAB.??
You need to add/modify the OSH ASM Header to keep the MPLAB happy.

E
Hi E,
I wish I could understand Hardware software and all you say, but "go to the dunces corner" I don't fully.

Anyway, STOP THE PRESS! using my stumbling about method of CODEing, I found a past program, which looked promising, so I moved things around till I think i've/we've got it working
EDIT: I've just been reminded why FUNCTIONs should be used here, so next I'll try to switch over from PROCEDURES to FUNCTIONS.
C

#### Attachments

• 6 KB Views: 1
• 273.8 KB Views: 2
Last edited:

#### ericgibbs

Joined Jan 29, 2010
14,207
hi,
Hardware is an item which physically exists within the PIC,
eg:
the Hardware Serial Port is 'etched' into the fabric of the PIC's internal semiconductor die.
it is also possible to write Code which uses other internal components of the PIC in order to create a secondary Software version of a Serial Port.

If you think about it, the PIC18FK4620 in the OSH IDE does not exist as a Hardware PIC , its the Software program of the IDE that is written to emulate the operation the PIC...

eg: it is a Software version of a PIC

E
It's not rocket science...

#### camerart

Joined Feb 25, 2013
2,767
hi,
Hardware is an item which physically exists within the PIC,
eg:
the Hardware Serial Port is 'etched' into the fabric of the PIC's internal semiconductor die.
it is also possible to write Code which uses other internal components of the PIC in order to create a secondary Software version of a Serial Port.

If you think about it, the PIC18FK4620 in the OSH IDE does not exist as a Hardware PIC , its the Software program of the IDE that is written to emulate the operation the PIC...

eg: it is a Software version of a PIC

E
It's not rocket science...
Hi E,
No it's not rocket science, but if I can clarify:
I have concentrated at all of these 'difficult to me' subjects, as they are explained, but if I'm programming, they don't recall, so I ignore them and move forward.

I've developed ways, that allow me to move forward, which onlookers must find odd. I put up with it, and move forward, so now you know why I'm not a rocket scientist.
C.

Last edited:

#### camerart

Joined Feb 25, 2013
2,767
Hi,
Here's a terminal READout and analayser view:
The READings are correct, in the terminal, even the ones where WRITE was used.
C.

#### Attachments

• 239.8 KB Views: 4