<h1>THE FORUM HAS MOVED,  VISIT US AT OUR NEW SITE www.picbasic.org. Access to this Archive is restricted. Visit the NEW site at www.picbasic.org.  Unless you use the url http://www.picbasic.org you will not gain access to the support forum, wiki and knowledge base. Visit WWW.PICBASIC.ORG  Do not try to log in or register here, use your keyboard and enter the url http://www.picbasic.org directly into your browser. </h1>  

Go Back  

THE FORUM HAS MOVED, VISIT US AT OUR NEW SITE www.picbasic.org. Access to this Archive is restricted. Visit the NEW site at www.picbasic.org. Unless you use the url http://www.picbasic.org you will not gain access to the support forum, wiki and knowledge base. Visit WWW.PICBASIC.ORG Do not try to log in or register here, use your keyboard and enter the url http://www.picbasic.org directly into your browser.

> Proton Development Suite > Proton Plus Compiler v3

Proton Plus Compiler v3 Coding problems and general discussion related to the Development Suite

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 8th February 2010, 05:28   #1
richardy
Forum User
 
Join Date: Jun 2006
Location: Hamilton, NZ
Posts: 96
richardy is on a distinguished road
Default serial input halting program execution

HI,
I have a program that reads serial input on three separate serial lines nad simply sends teh output on one serial line if something is recieved however occasionally (particualrly when all three serial lines are inputing data) program execution halts nad wont start again untill i remove all serial input from all three lines. If i then re-apply any or all of the serial stream input execution halts emediately nad the only soln is turn off and restart.

A program excerpt is below along with output from hyperterminal when the program halts.

Code:
'initialise chip
Device 18F1320
XTAL=20        

DelayMS 200
ALL_DIGITAL = true

'setup 18f chip 
@ CONFIG_REQ 
@ __CONFIG CONFIG1H, IESO_OFF_1 & FSCMEN_OFF_1 & HS_OSC_1
@ __CONFIG CONFIG2L, BORV_27_2 & BOR_ON_2 & PWRT_ON_2 
@ __CONFIG CONFIG2H, WDT_OFF_2 
@ __CONFIG CONFIG3H, MCLRE_OFF_3 
@ __CONFIG CONFIG4L, DEBUG_OFF_4 & LVP_OFF_4 & STVR_OFF_4 

'setup transmit 
RSOUT_PIN PORTA.3
RSOUT_MODE inverted      'for laptop
SERIAL_BAUD 38400

'Aliases
Symbol coms_out = PORTA.1
Symbol coms_in = PORTA.0
Symbol coms_freq = 16468
Symbol channel_0 = PORTB.4
Symbol channel_1 = PORTB.5
Symbol channel_2 = PORTB.6
Symbol channel_3 = PORTB.7
Symbol channel_4 = PORTB.0
Symbol channel_5 = PORTB.1
Symbol channel_6 = PORTA.2
Symbol channel_7 = PORTB.3

'variables nad initilisations
Dim tag_string As String * 25
Dim n As Byte
Dim m As Byte
Dim x As Byte
Dim reader_baud As Word
Dim ports As String * 10
Dim ports_str As String * 16
Dim len_ports_str As Byte
Dim port As Byte
Dim data_str As String * 7
Dim len_ports As Byte
Dim reader_speed As Byte
Dim timeout As Byte
Dim channel As Byte
Dim i As Byte
Dim num_ports As Byte
Dim channel_cnt As Byte

'program start
reader_baud = 9600
reader_speed = 10
timeout = 1000/reader_speed 'ms
num_ports = 3

n=0           
channel_cnt = 0

While 2 = 2
    channel_cnt = 0
    While 1 = 1                      ' Create an infinite loop    
        SerIn channel_0,reader_baud,timeout,here0,[Wait("L"),tag_string]         'make time out dependant on whether a reader is being used
        DelayMS 50
        RSOut "L0",tag_string,13
        here0:
        RSOut "L0",13                'testing
        'DelayMS 50
        Inc channel_cnt
        If channel_cnt = num_ports Then Break
    
        SerIn channel_1,reader_baud,timeout,here1,[Wait("L"),tag_string]
        DelayMS 50
        RSOut "L1",tag_string,13
        here1:
        RSOut "L1",13
        'DelayMS 50
        Inc channel_cnt
        If channel_cnt = num_ports Then Break
    
        SerIn channel_2,reader_baud,timeout,here2,[Wait("L"),tag_string]
        DelayMS 50
        RSOut "L2",tag_string,13
        here2:
        RSOut "L2",13
        'DelayMS 50
        Inc channel_cnt
        If channel_cnt = num_ports Then Break
    
     Wend

Wend
L0
L1W 0000 0000000000002081
L1
L2R 0000 0000000130831672
L2
L0R 0000 0000000130747231
L0
L1L˜02081
L1
L2R 0000 0000000130831672
L2
L0R 0000 0000000130747231
L0
L1W 0000 0000000000002081
L1
L2R 0000 0000000130831672
L2
L0R 0000 0000000130747231
L0
L1W 0000 0000000000002081
L1
L2M“¦CÂLR 0000 0000000130831672
L2 ------and execution halts
richardy is offline   Reply With Quote
Old 8th February 2010, 08:51   #2
Tim
Super Moderator
 
Tim's Avatar
 
Join Date: Jan 2003
Location: london
Posts: 8,196
Tim is on a distinguished road
Default

Think hard about what is happening in your serial in code. There are many scenarios of data coming over and you coming in in the middle of them.

For starters time out is only waiting for the first char not every char

I recommend you write your own serial control routine where you have a custom system that has time outs for every char and you can abandon a packet

I personally think you will never get it to work satisfactorily especially by trying to use off the shelf commands.

Far better you do it properly and and invest in a pick for every channel
__________________
Tim
If in doubt read the manual
Tim is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Serial & asci Peter Truman Proton Plus v2.1.5.3 General Discussion 5 6th May 2008 13:11
Microcode SFR view PORTA troubles boezio Proton Plus Compiler v3 8 25th February 2007 21:21
Major Port problem with 18F252/18F2420 Pkklause Proton User Site 1 30th November 2006 16:33
Registers grayed out!!! C_Moore Proton Plus Compiler v3 13 9th March 2005 21:17


All times are GMT +1. The time now is 09:43.



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright © Crownhill Associates Limited 2002 - 2009