BasicMicroUK - Forums

www.basicmicro.co.uk
It is currently Sun Apr 22, 2018 5:09 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: hserin and interrups
PostPosted: Thu Aug 30, 2012 12:46 pm 
Offline
New User

Joined: Thu Aug 30, 2012 12:29 pm
Posts: 2
Hello to all!
I encountered the following problem using BA40 with Basic Micro Studio. I need to organize an interrupt in which I implement certain functions for receiving message via RS232.
When I was working without using the interrupt I was using the function hserin.
In this variant all was working very well. The messages received by this function were correct and could be checked by the others applications working with the COM-port.
But it became necessary to use an interrupt to receive the message via RS232. But, unfortunately, if the messages come too often from an external device (over 3-5 times per second) the function hserin can’t receive them and keep waiting. If to use the function hserstat to help for the function hserin to work with a buffer, if messages are too frequent, all freezes on the function hserstat.
Please, can you advice sth in this situation? Because if the program is “freezed” even clearing the buffer by hserstat doesn’t help due to very frequent messages.
Code:
; Describing an interrupt
oninterrupt extint, message1
setextint ext_l2h
enable extint
enable   ; enables interrupts in general

SetHSerial1 H9600
ms var byte(17) ; array of receiving message

main   ; main program
   pause 3000
goto main


message1
   disable extint   
   getdata
   hserstat 4, getdata; waiting for the buffer to get ready
   hserin [ms(0),ms(1),ms(2),ms(3),ms(4),ms(5),ms(6),ms(7),ms(8),ms(9),ms(10),ms(11),ms(12),ms(13),ms(14),ms(15),ms(16)]
   enable extint
resume



Top
 Profile  
 
 Post subject: Re: hserin and interrups
PostPosted: Thu Aug 30, 2012 5:33 pm 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 7:00 pm
Posts: 1316
Location: Temecula, CA
Why are you doing this? Please be specific because I don't see any reason why you would need to use an interrupt to handle the buffered serial data. WHy aren't you just checking the external pin in your main program loop?

In any case the problem is you are pausing 3000 in your main loop. Basic interrupts on the Atom line of processors are only processed between basic commands in your main program so no matter what this program will only process serial data every 3 seconds. If you want a true interrupt you need to use an asm interrupt(which would preclude using the hserin commands since they are basic or switching to the AtomPro processor which is much more powerful and handles basic interrupts just like asm interrupts instead of waiting between basic commands.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: hserin and interrups
PostPosted: Fri Aug 31, 2012 7:03 am 
Offline
New User

Joined: Thu Aug 30, 2012 12:29 pm
Posts: 2
Thank you very much for the answer. Of course the main program will be much bigger than just one pause. I showed just the idea how I organized the interrupt. As I understood in this situation I have to use asm code and asm interrupts. But firstly I wanted to use just interrupts available in Basic Micro language.

Thank you! Maybe you can show me any example?


Top
 Profile  
 
 Post subject: Re: hserin and interrups
PostPosted: Wed Sep 05, 2012 6:27 pm 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 7:00 pm
Posts: 1316
Location: Temecula, CA
Please post a detailed description of your project and I'll see what I can do.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO