Settings:
quartz = 20MHz
PLL prescaler = divide by 5
system clock = OSC1/OSC2 Src1
USB clock source selection = Clk src from 96MHz PLL/2
Oscillator = HS+PLL, USB-HS
Watchdog = disabled
Code: Select all
program TestDelay_ms;
uses
USBdsc;
var
userWR_buffer: array[2] of Byte;
userRD_buffer: array[2] of Byte;
//******************************************************************************
// Main Interrupt Routine
//******************************************************************************
procedure interrupt;
begin
HID_InterruptProc;
end;
//******************************************************************************
//******************************************************************************
// Initialization Routine
//******************************************************************************
procedure Init_Main;
begin
//--------------------------------------
// Disable interrupts
//--------------------------------------
INTCON := 0; // Disable GIE, PEIE, TMR0IE,INT0IE,RBIE
INTCON2 := 0xF5;
INTCON3 := 0xC0;
RCON.IPEN := 0; // Disable Priority Levels on interrupts
PIE1 := 0;
PIE2 := 0;
PIR1 := 0;
PIR2 := 0;
//ADCON1 := ADCON1 or 0x0F; // Configure all ports with analog function as digital
ADCON1 := 12; // AN0, AN1, AN2, others digital
//--------------------------------------
// Ports Configuration
//--------------------------------------
TRISA := 0;
TRISB := 255;
TRISC := 0;
TRISD := 2;
TRISE := 0;
LATA := 0;
LATB := 0;
LATC := 0;
LATD := 0;
LATE := 0;
//--------------------------------------
// Clear user RAM
// Banks [00 .. 07] ( 8 x 256 = 2048 Bytes )
//--------------------------------------
end;
begin
Delay_mS(1000);
Init_Main;
HID_Enable(@userRD_buffer, @userWR_buffer);
Delay_mS(2000);
repeat
if PortD.1 = 0 then //button
begin
LATD.0 := 1; //LED on
Delay_ms(5000);
LATD.0 := 0; //LED off
end;
until False;
end.
Delay_ms(1000) => 0.4s
Delay_ms(5000) => 2.2s
Delay_ms(6000) => 2.6s
Delay_ms(10000) => 4.3s
Delay_ms(60000) => 25.2s