Monthly Archives: August 2015

PIC16F684 Blink LED with PICkit 3

This post is for beginners who would like to run a simple LED blinking example using PIC16F684 with PICkit 3. Most of the beginners may start learning by using Demo board that is usually shipped with the PICkit 3 but this post aims to connect PICkit 3 directly to the PIC16F684. This post assumes that MPLAB IDE and XC8 compiler have been successfully installed.

PICkit 3 is a programmer and debugger for PIC microcontollers. PICkit 3 has 6 pins but pin 6 is not used in our case. Here is the connection between PICkit 3 and PIC16F684

PICkit 3 pins on the left and PIC16F684 pins on the right
pin 1 <-----> pin 4 
pin 2 <-----> pin 1 (Vdd)
pin 3 <-----> pin 14 (Vss)
pin 4 <-----> pin 13
pin 5 <-----> pin 12

In this example, an LED is connected to PIC16F684 on pin number 9 (RC1) and the other side is to ground. Note that pin 14 (Vss) acts as ground. Also, internal clock of the PIC16F684 is used so configuration bit of FOSC must be set to INTOSCIO. Here is the code for blinking an LED on port RC1.

#include <stdio.h>
#include <stdlib.h>
#include <xc.h>

#pragma config FOSC = INTOSCIO
#pragma config WDTE = OFF 
#pragma config PWRTE = OFF 
#pragma config MCLRE = OFF 
#pragma config CP = OFF 
#pragma config CPD = OFF 
#pragma config BOREN = OFF 
#pragma config IESO = OFF 
#pragma config FCMEN = OFF 

#define _XTAL_FREQ 8000000
int main(int argc, char** argv) {

 TRISCbits.TRISC1 = 0;
 ANSEL = 0;


 RC1 = 0;
 RC1 = 1;
 return (EXIT_SUCCESS);


iOS Objective C: Obtaining MAC address of an IP from ARP Table

There are many reasons where one might want to obtain a MAC address of a host (or network device) in a local area network given a valid IP address to be used in iOS application development. In computer networking, Address Resolution Protocol (ARP) is used for resolution of a network layer address into a link layer address. Typically ARP involves exchanging ARP messages to obtain MAC address of a host given that IP address of the host is known. This link provides a nice explanation of ARP.

ARP table is a cache which stores IP addresses and associated MAC addresses of the network devices. Smartphones such as Android and iOS platforms also contain an ARP table. One can view ARP table on Mac OS X by using terminal and type command:

arp -a
( at e8:fc:af:ff:99:d5 on en0 ifscope [ethernet]
( at 80:ea:96:e6:55:4f on en0 ifscope [ethernet]
( at a4:5e:60:bd:5b:2d on en0 ifscope permanent [ethernet]
( at f4:f9:51:d3:e:35 on en0 ifscope [ethernet]
( at f4:f9:51:d3:e:36 on en0 ifscope [ethernet]
( at ff:ff:ff:ff:ff:ff on en0 ifscope [ethernet]

If we could programmatically access ARP table we could also obtain a MAC address of the associated IP address. Thanks to Evgeniy Kapralov who posted arpmac project on GitHub in accessing ARP table of the iOS device programmatically.

Why do we need this? Well, iOS 8 does not provide APIs in accessing ARP table and there may be cases where one might want to programmatically determine MAC address of a network device on iOS platform.