Hallo Leute,
Will bei einem PIc18F14k50 den USB Interruptbetrieb und den Sleep mode
gmeinsam nutzen.
Leider funktioniert das nicht so richtig. Hier mein Quellcode:
sub procedure Interrupt()
USB_Interrupt_Proc()
if (HID_Read() > 0) then
Led = 1
if CheckSystemCommand = 0 then
Read_Sht
Convert_Data_to_text
end if
while(HID_Write(@USB_writebuf,42) = 0)
NOP
wend
Led = 0
end if
end sub
main:
InitConfig 'Set input,Outputs,...
ReadEEpromDatas 'Offsets,serial,...
HID_Enable(@USB_readbuf,@USB_writebuf)
delay_ms(1500)
Led = 0
while TRUE
sleep
nop 'Some Operations to starting up the OSC
nop
nop
nop
nop
nop
nop
nop
nop
wend
Weis jemand, wie ich das Problem umgehen kann?
Nimm ein lauffähiges Projekt von Microchip und hangel dich durch. Was für eine Programmiersprache verwendest Du da? Gruß Potter
Das ist Mikrobasic. Leider finde ich nichts vergleichbares :-(
Du setzt keine Bedinngung, wenn er aus dem Sleepmodus aufwachen soll. So bleibt er immer im Sleep Modus.
Bedingung wird schon gesetzt.
Sub Procedure InitConfig
Intcon.GIE = 0 'All Interrupts off
ADCON0 = 0
ADCON1 = 0
ANSEL = 0
ANSELH = 0
CCP1CON = 0
RCON.IPEN = 0 'Disable Interrupt priority
INTCON.PEIE = 1 'PIR is on
INTCON2.rabpu = 1 'Pullups disabled
PIE2.USBIE = 1 'Enable USB Interrupt
'Pins, that will be always high:
PortC.5 = 1 'Dummy Pin
TrisC.5 = 0 'Dummy Pin
PortC.7 = 1 'Led
TrisC.7 = 0 'Led
PortB.7 = 1 'Vdd from SHT
TrisB.7 = 0 'Vdd from SHT
'Pins, taht will be always low:
PortC.4 = 0 'Dummy Pin
TrisC.4 = 0 'Dummy Pin
PortC.3 = 0 'Dummy Pin
TrisC.3 = 0 'Dummy Pin
PortC.6 = 0 'Dummy Pin
TrisC.6 = 0 'Dummy Pin
PortC.0 = 0 'Dummy Pin
TrisC.0 = 0 'Dummy Pin
PortC.1 = 0 'Dummy Pin
TrisC.1 = 0 'Dummy Pin
PortC.2 = 0 'Dummy Pin
TrisC.2 = 0 'Dummy Pin
PortB.4 = 0 'Dummy Pin
TrisB.4 = 0 'Dummy Pin
'Pins that would be an Input
TrisB.5 = 1
TrisB.6 = 1
Intcon.GIE = 1 'Enables Global Interrupt
end sub
Wegen dem funktioniert es noch immer nicht :-(
Habe folgendes Dokument studiert: http://ww1.microchip.com/downloads/en/AppNotes/00950b.pdf Aber leider funktioniert das auch nicht :-(
Funktioniert :-D
while TRUE
Pir2.USBIE = 1 'Set the Interrupt on
UIE.SOFIE = 1 'Set the Interrupt on
OSCCON.IDLEN = 1 'Switch to internal Oscillator
sleep
nop 'Some Operations to starting up the OSC
nop
nop
nop
nop
nop
nop
nop
nop
wend
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.