Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

ollopa's swusb and timers

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
Sebastian.Heyn

Bascom Member



Joined: 13 Apr 2005
Posts: 84

PostPosted: Mon Oct 13, 2014 10:07 am    Post subject: ollopa's swusb and timers Reply with quote

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
View user's profile
EDC

Bascom Expert



Joined: 26 Mar 2014
Posts: 727

poland.gif
PostPosted: Mon Oct 13, 2014 4:12 pm    Post subject: Reply with quote

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 Very Happy


This Quote is taken from here
Back to top
View user's profile Visit poster's website
Sebastian.Heyn

Bascom Member



Joined: 13 Apr 2005
Posts: 84

PostPosted: Mon Oct 13, 2014 7:50 pm    Post subject: Reply with quote

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
View user's profile
Sebastian.Heyn

Bascom Member



Joined: 13 Apr 2005
Posts: 84

PostPosted: Mon Oct 13, 2014 8:09 pm    Post subject: Reply with quote

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
View user's profile
Sebastian.Heyn

Bascom Member



Joined: 13 Apr 2005
Posts: 84

PostPosted: Mon Oct 13, 2014 8:13 pm    Post subject: Reply with quote

This is the part that takes up most of the cpu time

Code:

Akey = Usb_check_rx()
 
Back to top
View user's profile
Sebastian.Heyn

Bascom Member



Joined: 13 Apr 2005
Posts: 84

PostPosted: Mon Oct 13, 2014 9:14 pm    Post subject: Reply with quote

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 Smile)

I think I'll have to use 2 chips and use uart polling...
Back to top
View user's profile
Evert :-)

Bascom Expert



Joined: 18 Feb 2005
Posts: 2126

netherlands.gif
PostPosted: Tue Oct 14, 2014 9:48 pm    Post subject: Reply with quote

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
View user's profile Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive 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