Goede middag,

Voor het eerst eens wat bezig PWM in proton. Maar het volgende probleem heb ik, als ik een simpel programma laat afdraaien zonder HPWM dan gaat alles goed tot ik de regel HPWM er bij zet dan loopt hij het hele programma niet meer af? Nu heb ik in een ander project wel pwm draaiende maar dit draait op interne osc kan dit er nog mee te maken hebben?


Device = 16F887

Config1 DEBUG_OFF , LVP_OFF , FCMEN_OFF , IESO_OFF , BOR_OFF , CPD_OFF , CP_OFF , MCLRE_off , PWRTE_ON , WDT_OFF , HS_OSC
Config2 WRT_OFF , BOR21V    
                     
Declare Xtal = 20
;===============================================================================
;Symbolen
;===============================================================================
Symbol ID_SendSer   = PORTB.0
Symbol ID_LDR       = PORTB.1
Symbol ID_PIR       = PORTB.2
Symbol OD_StatusLed = PORTE.2

;Symbol M_Aan        = 0
;Symbol M_Uit        = 1
Symbol M_Actief     = 1
Symbol M_InActief   = 0
;===============================================================================
;Variabelen
;===============================================================================
Dim TijdAan             As Word        ;Tijd in seconden
Dim LSR                 As Byte        ;Lichtsterkte rust
Dim Teller              As Word
Dim TellermS            As Word
Dim AanBit              As Bit
Dim Duty                As Byte
Dim DimBit              As Bit
;===============================================================================
;Poort instellingen
;===============================================================================
        ;76543210
TRISA = %00000000    ;TRIS instellingen : 1 is ingang - 0 is uitgang                            
TRISB = %11111111                        
TRISC = %00000000                         
TRISD = %00000000                         
TRISE =      %000 

PORTA = %00000000    ;PORT instellingen : 1 is hoog - 0 is laag                     
PORTB = %11111001                         
PORTC = %00000000                         
PORTD = %00000000                          
PORTE =      %000                                                          
;===============================================================================
;Declares
;===============================================================================
All_Digital TRUE
;===============================================================================
;===============================================================================
;Instellingen
;===============================================================================                                   
Clear
AanBit      = 0
Teller      = 0
TellermS    = 0
DimBit      = 0
DelayMS 500

GoTo Main
;===============================================================================
;Main
;===============================================================================
Main:


;hpwm 1, 100, 2000

While 1 = 1

If ID_PIR = M_Actief Then
    AanBit = 1
    OD_StatusLed = 0        ;1 = aan
ElseIf ID_PIR = M_InActief Then
    AanBit = 0
EndIf

;--Status led---------------------------------------
If AanBit = 0 Then
    DelayMS 25
    Toggle OD_StatusLed                             ;Knipper status led
EndIf

Wend
End

Je bent 'n Declare vergeten.
Welke poort wil je gebruiken (bv. PORTC.2)
Dan wordt dit;
Declare CCP1_Pin PORTC.2

Super dat werkt idd. Ben er gelijk achter gekomen dat je onder de laagst bruikbare frequentie gaat icm cristal dan gaat hij ook erg raar doen. Opgelost bedankt!