System Development
Coding Examples
Basic Setup
6min
for more information about the pic16f18875 | pic16f18877 in the code sample below, the device is set up to use portb and porte to flash an led this is a simple project and is often used as a "heartbeat" to ensure that the device is working the code sample below is written in mikro c, available from mikroe main () the code is initiated by first setting up the device and then going into a continual loop flashing the designated pin setup device() the device setup does the following the analogs for each port are disabled, as we will be using them as digital i/o all the pins are set to input ony the designated pins are set for outputs comparators are also disabled flash pin() the pin on port# bit 0 is toggled once every 500ms code sample the sample described above is listed below use the copy function to extract the code for use / test code for pic16f18877 / void setup device(); void flash pin(); void flash pin(){ latb b0 = latb b0; delay ms(500); late b0 = late b0; delay ms(500); } void setup device(){ // switch off analogs ansela = 0x00; anselb = 0x00; anselc = 0x00; anseld = 0x00; ansele = 0x00; // trisb = 0b11111110; trise = 0b11111110; // comparators c1on bit = 0; // disable comparators c2on bit = 0; } void main() { setup device(); while(1){ flash pin(); // flash the led } } parts list to complete this project the following is needed radix duo (with pic16f18875 | pic16f18877) + radix shield alternatively, you may use the following radix duo (with pic16f18875 | pic16f18877) 820 ohm resistor 3 or 5 mm led \[end]