• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Need help with SERIN timeout

Thread starter #1
Hello friends,

Need help with the below code.

Code:
Define SERIN_TIMEOUT_REG = INTCON
Define SERIN_TIMEOUT_BIT = TMR0IF

slave:
i = 0
slaveready = False
Serout PORTB.0, 9600, "A", CrLf

loop:

    Serin PORTB.1, 9600, serdata  'GETS STUCK HERE WHEN NOTHING RECEIVED
   
        If serdata > 0 Then
        If serdata = "K" Then
            slaveready = True
              Return
        Endif
        Endif

    i = i + 1
If i = 1000 Then Return

Goto loop
    Return
The timeout occurs very soon, is there a way to slow it ?

Cheers
Mastero
 
Last edited by a moderator:

Ian Rogers

User Extraordinaire
Forum Supporter
Most Helpful Member
#2
Even in Oshonsoft you can check the RCIF flag..

while TIMEOUT < 1000
if RCIF then serget PORTB.1, 9600, serdata
TIMEOUT = TIMEOUT + 1
wend

I haven't tested this code so puppy steps...
 
Thread starter #3
No the above code will not work in Osho....

solution was

Define SERIN_TIMEOUT_REG = PORTB
Define SERIN_TIMEOUT_BIT = 1

Timeout Bit was tied to serin pin works perfectly.

Thanx
 

Ian Rogers

User Extraordinaire
Forum Supporter
Most Helpful Member
#4
So why ask for help if it works....

I have stopped using Oshonsoft, and the timeout bit is a newer feature... However... My way will also work as serget doesn't wait, I only call when something is there..
 
Thread starter #5
Hello Ian,

When i asked for help it was night here (India) trail and test whole night and found solution before bed time :)
morning saw your post and replied SORRY :)

Neways the serget does not exist in Osho.

Hserget is there but i am already using it for GSM module communication.

I am looking for Soft Uart routine which waits for a say 50ms and returns "0" if nothing on serin port..... have anything in mind ?

Define SERIN_TIMEOUT_REG = PORTB
Define SERIN_TIMEOUT_BIT = 1

Is also very fast as i am using 20mhz external with 18f2520 have to put a 10000 check then exit

Any ideas?

Thanx in advance
Mastero
 
Last edited:

Latest threads

EE World Online Articles

Loading

 
Top