View previous topic :: View next topic |
Author |
Message |
Sebastian.Heyn
Joined: 13 Apr 2005 Posts: 86
|
Posted: Mon Oct 13, 2014 10:07 am Post subject: ollopa's swusb and timers |
|
|
Hi,
I intent to use a timer (counter, NO INTERRUPT) for a project (remote controller-> USB Keyboard adaptor).
I got
1) USB working (typemessage works)
2) Remote working (I changed from interrupt to no interrupt first, which was the first step to integrate both parts)
but both combined doesnt work, timer1 seems to give unlogical values
Does anyone know whether timer1 or timer0 is used by ollopas library?
(BASCOM-AVR version : 2.0.7.6 , Latest : 2.0.7.7 ) |
|
Back to top |
|
|
EDC
Joined: 26 Mar 2014 Posts: 971
|
Posted: Mon Oct 13, 2014 4:12 pm Post subject: |
|
|
Quote: | it is not confusing. if I remember it right, Opalla pointed out somewhere that you cannot use own interrupts with his lib. The USB speed is so high and time-critical, that the USB routines must have absolute priority. Using own interrupts, you disturb the USB timing.
You may use timers, but you have to poll them. Own interrupts are forbidden. |
Now I read so You don`t have interrupts. Sorry
This Quote is taken from here |
|
Back to top |
|
|
Sebastian.Heyn
Joined: 13 Apr 2005 Posts: 86
|
Posted: Mon Oct 13, 2014 7:50 pm Post subject: |
|
|
Yeah I use no interrupts.
the code looks a bit like this
if pinb.1=0 then
timer0=0
start timer0
do
loop until pinb.1=1
stop timer0
a=timer0
message=str(a)
endif
Code: |
if pinb.1=0 then
timer0=0
start timer0
do
loop until pinb.1=1
stop timer0
a=timer0
message=str(a)
call typemessage(message)
endif
|
I should get timer values of about 90 something, but i get 1-5. As I said the program using the timers (remote code reader) works fine for my dimmer project... |
|
Back to top |
|
|
Sebastian.Heyn
Joined: 13 Apr 2005 Posts: 86
|
Posted: Mon Oct 13, 2014 8:09 pm Post subject: |
|
|
Looks like I found the issue. If anyone has an idea howto implement this anyway, please let me know!
Code: |
do 'main loop
portb.0=1
Resetcounter = 0
Call Usb_check_reset
Akey = Usb_check_rx()
portb.0=0
.
.
.
.
my code bla bla
poll input
bla bla
loop 'main loop
end
|
so looks like the portb.0 is high most of the time. So there is a veeery high chance to miss the startbit of the remote transmission. |
|
Back to top |
|
|
Sebastian.Heyn
Joined: 13 Apr 2005 Posts: 86
|
Posted: Mon Oct 13, 2014 8:13 pm Post subject: |
|
|
This is the part that takes up most of the cpu time
Code: |
Akey = Usb_check_rx()
|
|
|
Back to top |
|
|
Sebastian.Heyn
Joined: 13 Apr 2005 Posts: 86
|
Posted: Mon Oct 13, 2014 9:14 pm Post subject: |
|
|
ok
one step further, I was able to block the usb_rx call by using a loop and a counter.
However - the int0 usb_isr takes up just as much time )
I think I'll have to use 2 chips and use uart polling... |
|
Back to top |
|
|
Evert :-)
Joined: 18 Feb 2005 Posts: 2156
|
Posted: Tue Oct 14, 2014 9:48 pm Post subject: |
|
|
That's a little bit the disadvantage of software usb stack, it consumes a lot of resources.
You can try a hardware usb avr with the Bascom USb Addon.
Did numerous projects with it, no problems at all so far. _________________ www.evertdekker.com Bascom code vault |
|
Back to top |
|
|
|