include 16f628a --
--
-- This program assumes a 20 MHz resonator or crystal
-- is connected to pins OSC1 and OSC2.
pragma target clock 20_000_000 -- oscillator frequency
-- configuration memory settings (fuses)
pragma target OSC HS -- HS crystal or resonator
pragma target WDT disabled -- no watchdog
pragma target LVP disabled -- no Low Voltage Programming
pragma target MCLR external -- reset externally
--
alias led is pin_A0
pin_A0_direction = output
enable_digital_io() -- \
forever loop
led = on
_usec_delay ( 250000 )
led = off
_usec_delay ( 250000 )
end loop
Code: 58/2048 Data: 4/208 Hardware Stack: 0/8 Software Stack: 80
-- Symbolic Fuse definitions
-- -------------------------
--
-- addr 0x2007
--
pragma fuse_def OSC 0x13 { -- oscillator
RC_CLKOUT = 0x13 -- rc: clkout on ra6/osc2/clkout, rc on ra7/osc1/clkin
RC_NOCLKOUT = 0x12 -- rc: i/o on ra6/osc2/clkout, rc on ra7/osc1/clkin
INTOSC_CLKOUT = 0x11 -- intosc: clkout on ra6/osc2/clkout, i/o on ra7/osc1/clkin
INTOSC_NOCLKOUT = 0x10 -- intosc: i/o on ra6/osc2/clkout, i/o on ra7/osc1/clkin
EC_NOCLKOUT = 0x3 -- ec
HS = 0x2 -- hs
XT = 0x1 -- xt
LP = 0x0 -- lp
}
pragma fuse_def WDT 0x4 { -- watchdog timer
ENABLED = 0x4 -- on
DISABLED = 0x0 -- off
}
pragma fuse_def PWRTE 0x8 { -- power up timer
DISABLED = 0x8 -- disabled
ENABLED = 0x0 -- enabled
}
pragma fuse_def MCLR 0x20 { -- master clear enable
EXTERNAL = 0x20 -- enabled
INTERNAL = 0x0 -- disabled
}
pragma fuse_def BROWNOUT 0x40 { -- brown out detect
ENABLED = 0x40 -- enabled
DISABLED = 0x0 -- disabled
}
pragma fuse_def LVP 0x80 { -- low voltage program
ENABLED = 0x80 -- enabled
DISABLED = 0x0 -- disabled
}
pragma fuse_def CPD 0x100 { -- data ee read protect
DISABLED = 0x100 -- disabled
ENABLED = 0x0 -- enabled
}
pragma fuse_def CP 0x2000 { -- code protect
DISABLED = 0x2000 -- off
ENABLED = 0x0 -- on
}
pragma target clock 4_000_000 -- ,
--
pragma target OSC INTOSC_NOCLKOUT --
pragma target WDT disabled --
pragma target PWRTE disabled --
pragma target MCLR external --
pragma target BROWNOUT disabled --
pragma target LVP disabled --
pragma target CPD disabled -- EEPROM
pragma target CP disabled --
However, the pull-up resistor is not always necessary. All PORTB legs (RB0-RB7) have an internal tightening programmatically connected. But the use of external braces is much safer.
enable_digital_io() -- \
--
alias led is pin_B5 -- RB5
pin_B5_direction = output -- RB5
--
alias button is pin_B4 -- RB4
pin_B4_direction = input -- RB4
led = off --
forever loop
led = off --
_usec_delay ( 500000 ) -- 0,5
if Button == 0 then -- ,
led = on --
_usec_delay ( 500000 ) -- 0,5
end if
end loop
Errors: 0 Warnings: 0
Code: 60/2048 Data: 4/208 Hardware Stack: 0/8 Software Stack: 80
Poor-quality soldering is one of the main problems of the device’s inoperability.
Do not repeat my bad habits: do not use mounted installation.
In this case, the tail from the old PS / 2 mouse inserted into the mouse connector was used as the 5V power supply.
From the programmer, only the high voltage (12V) on the MCLR prevents us. In order not to solder the entire programmer, you can only solder one wire ... Or simply do not connect the programmer to the COM port. The rest of the wires will not disturb us (and the connected power and ground will only simplify the soldering).
When you re-connect the programmer, the resistor will need to be removed, otherwise it will pull 12v to power.
Source: https://habr.com/ru/post/97795/