PIC18F14k50 USB & Sleep will nicht -> Expertenrat gesucht

Gast #2302248
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?
Gast #2302339
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 :-(
Gast #2302391
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

Antwort schreiben

Eine eigene Frage? Dieser Thread ist über 15 Jahre alt. Stell sie in einem eigenen Thread – dort lesen mehr Leute mit, und sie wird öfter und schneller beantwortet.

Neuen Thread starten

Eine Lösung, Ergänzung oder Rückmeldung zu diesem Thread? Dann antworte hier.

Formatierung
  • [c]C-Code[/c]
  • [code]Code in anderen Sprachen, ASCII-Zeichnungen[/code]
  • [math]Formel in LaTeX-Syntax[/math]
  • [[Titel]] – Link zu einem Artikel
  • Verweis auf einen anderen Beitrag: Rechtsklick auf dessen Beitrags-ID (#8078628), „Adresse kopieren“, in den Text einfügen

Mehr zur Formatierung

Längeren Sourcecode als Anhang, nicht in den Text. JPG nur für Fotos und Scans; Zeichnungen und Screenshots als PNG oder GIF. Siehe Bildformate.

Schon registriert? Anmelden

Wird nicht angezeigt. Wir schicken dir einen Link; sobald du damit bestätigst, erscheint dein Beitrag.

Mit dem Abschicken legst du einen kostenlosen Account an und erkennst die Nutzungsbedingungen und die Datenschutzerklärung an.