View previous topic :: View next topic |
Author |
Message |
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
Posted: Fri Feb 26, 2021 7:29 pm Post subject: ischarwaiting and interrup [solved] |
|
|
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
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 |
|
|
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
Posted: Fri Feb 26, 2021 8:34 pm Post subject: |
|
|
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 |
|
|
JC
Joined: 15 Dec 2007 Posts: 585 Location: Cleveland, OH
|
Posted: Fri Feb 26, 2021 8:41 pm Post subject: |
|
|
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 |
|
|
SZTRAD
Joined: 30 Dec 2019 Posts: 165
|
Posted: Sat Feb 27, 2021 8:49 am Post subject: |
|
|
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 |
|
|
Pikczu
Joined: 22 Jan 2006 Posts: 72 Location: Dublin, Ireland
|
Posted: Mon Mar 01, 2021 7:13 pm Post subject: |
|
|
I use Ischarwaiting for 4d systems displays and everything is working fine.
The key part is the buffer. |
|
Back to top |
|
|
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
Posted: Wed Mar 03, 2021 5:09 pm Post subject: |
|
|
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
_________________ pleasure to learn, to teach, to create |
|
Back to top |
|
|
|