Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

ischarwaiting and interrup [solved]

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 1161
Location: France

france.gif
PostPosted: Fri Feb 26, 2021 7:29 pm    Post subject: ischarwaiting and interrup [solved] Reply with quote

Hi all,
I use the "ischarwaiting" function in a loop with the nextion screens (which communicates in series), in my loop I read the value of the second returned by the RTC of the display, it happens that I miss the information of the touch screen.
With the classic screens (SSD1963) which use an interruption as soon as you touch the screen you react very quickly independently of the RTC.
I would like to use the an interrupt with ischarwaiting if it is possible ?
I use Atmega1284P
could you explain how to do? I'm looking but nothing works
Thanks
Rolling Eyes Crying or Very sad JP

(BASCOM-AVR version : 2.0.8.3 )

_________________
pleasure to learn, to teach, to create


Last edited by Duval JP on Wed Mar 03, 2021 4:59 pm; edited 1 time in total
Back to top
View user's profile Visit poster's website
i.dobson

Bascom Expert



Joined: 05 Jan 2006
Posts: 1570
Location: Basel, Switzerland

switzerland.gif
PostPosted: Fri Feb 26, 2021 8:34 pm    Post subject: Reply with quote

Hi JP,

Show us abit of code that shows your problem. Maybe you could use the serial receive interrupt or the Bytematch
option if your using buffered serial input.

Regards
Ian Dobson

_________________
Walking on water and writing software to specification is easy if they're frozen.
Back to top
View user's profile
JC

Bascom Member



Joined: 15 Dec 2007
Posts: 586
Location: Cleveland, OH

usa.gif
PostPosted: Fri Feb 26, 2021 8:41 pm    Post subject: Reply with quote

Not at home so can't check this on any real hardware at the moment.

I suspect you are using Bascom's USART RxData ring buffered, interrupt driven, driver for your incoming serial comm's.

I suspect IsCharWaiting just looks at a flag to see if there is any data in the ring buffer, (i.e. is the buffer empty or not).

It might be challenging, therefore, to fire your own interrupt on the USART Rx Data flags, as you will be competing with the above driver.

A work-around hack might be to set up a Timer/Counter to generate an interrupt once every 1 mSec, (or whatever).
Then, within your own ISR you simply run the IsCharWaiting instruction.
That lets the Bascom driver handle the actual USART ISR and ring buffer, and lets your code (ISR) periodically check for new data.

That would use a fair amount of overhead processing, but depending upon what the rest of the system is doing it might not matter.

JC
Back to top
View user's profile Visit poster's website
SZTRAD

Bascom Member



Joined: 30 Dec 2019
Posts: 165

blank.gif
PostPosted: Sat Feb 27, 2021 8:49 am    Post subject: Reply with quote

Hello
colleague is right. The command tests the flag at position 7 of the status register.
If the ensuing loop is longer than the communication speed, the data will be lost. So, as colleague above wrote, you have two choices. Either generate an interrupt shorter than the communication speed and test the flag in the subroutine, or execute the command more frequently in the program body. Easier for resources would probably be to write down the routine of running interruptions on Uart.

RS
Back to top
View user's profile
Pikczu

Bascom Member



Joined: 22 Jan 2006
Posts: 72
Location: Dublin, Ireland

ireland.gif
PostPosted: Mon Mar 01, 2021 7:13 pm    Post subject: Reply with quote

I use Ischarwaiting for 4d systems displays and everything is working fine.
The key part is the buffer.
Back to top
View user's profile
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 1161
Location: France

france.gif
PostPosted: Wed Mar 03, 2021 5:09 pm    Post subject: Reply with quote

Well... It is solved
solution:
with nextion, you have to fill a array with the bytes returned
my errors
1- I had dimensioned my array a little too big
2- I didn't reset this one at each nextion function call, so I reread my array filled with seconds values instead of reading the answer to a key.

anyway thanks to each Bascom users for your help
JP
Wink

_________________
pleasure to learn, to teach, to create
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum