Let's find out together what makes a PIC Tick!
Started by trastikata, May 09, 2023, 07:22 AM
QuoteSleep uses the Watchdog Timer so it is independent of the oscillator frequency
Proc SleepFor2ms() Dim bTimerCortCnt As Byte If xBPWMRequired = cFalse Then ; No sleeping while PWM is active fTmr_Enable = cFalse ; First stop the timer Inc bTimerCortCnt If bTimerCortCnt >=4 Then bTimerCortCnt = 0 dMS_Timer = dMS_Timer + 3 ; Correction value Else dMS_Timer = dMS_Timer + 2 EndIf WDTCON0 = %00000011 ' sleep for c2ms Sleep Nop fTmr_Enable = cTrue ; Re start the timer WDTCON0 = 0 Else DelayMS 2 EndIfEndProc
Quote from: trastikata on May 09, 2023, 07:22 AMIt is not clear to me how the compiler behaves when using the Sleep command and the Watchdog is disabled in the Configuration bits? Another question here - does the compiler take into consideration the Watchdog pre/post scaler as set in the Configuration bits?