Good evening,
this is my 1st post in Swordfish forum, please have lenity with me
I played today the first time with the compiler, ... hours later .... I looked into the HID example and tried to modify it and added a 2nd timer. The new timer should drive a software clock but surprise surprise it doesn't work, the newly generated timer never fires. Reading through the forum I used a low priority interrupt but also with no success, after removing the usbhid.bas libaray the timer starts working. Can somebody give me a hint how to use multiple interrupts with USB?
madru
USB and interrupts
Moderators: David Barker, Jerry Messina
Re: USB and interrupts
.....here is the code I used, any ideas?madru wrote:Good evening,
this is my 1st post in Swordfish forum, please have lenity with me
I played today the first time with the compiler, ... hours later .... I looked into the HID example and tried to modify it and added a 2nd timer. The new timer should drive a software clock but surprise surprise it doesn't work, the newly generated timer never fires. Reading through the forum I used a low priority interrupt but also with no success, after removing the usbhid.bas libaray the timer starts working. Can somebody give me a hint how to use multiple interrupts with USB?
madru
THX
Code: Select all
Dim TMR0ON As T0CON.7
Dim T08BIT As T0CON.6
Dim T0CS As T0CON.5
Dim T0SE As T0CON.4
Dim PSA As T0CON.3
Dim T0PS2 As T0CON.2
Dim T0PS1 As T0CON.1
Dim T0PS0 As T0CON.0
Dim TMR0IF As INTCON.2
Code: Select all
Interrupt clock(iplow)
Toggle(LED)
If TMR0IF = 1 Then
TMR0H = $15 // preset for Timer0 MSB register
TMR0L = $A0 // preset for Timer0 LSB register
Dec(int_counter)
If int_counter = 0 Then
int_counter = Int_Total ' count 100 interrupts @ 10000us = 1 second
update = true ' update clock
End If
TMR0IF = 0 // reset the interrupt flag
End If
End Interrupt
Code: Select all
Sub Initialize()
INTCON = %10100000
// Timer0 Registers:
// 16-Bit Mode ; Prescaler=1:2
// TMRH Preset = $15
// TMRL Preset = $A0
// Freq = 100.00Hz
// Period = 10.00 ms
TMR0ON = 1 // Timer0 On/Off Control bit:1=Enables Timer0 / 0=Stops Timer0
T08BIT = 0 // Timer0 8-bit/16-bit Control bit: 1=8-bit timer/counter / 0=16-bit timer/counter
T0CS = 0 // TMR0 Clock Source Select bit: 0=Internal Clock (CLKO) / 1=Transition on T0CKI pin
T0SE = 0 // TMR0 Source Edge Select bit: 0=low/high / 1=high/low
PSA = 0 // Prescaler Assignment bit: 0=Prescaler is assigned; 1=NOT assigned/bypassed
T0PS2 = 0 // bits 2-0 PS2:PS0: Prescaler Select bits
T0PS1 = 0
T0PS0 = 0
TMR0H = $15 // preset for Timer0 MSB register
TMR0L = $A0 // preset for Timer0 LSB register
TMR0ON = 1 // start Timer0
Enable(clock)
End Sub