My experiments with PIC

I relocated to Coimbatore recently and since then it has been difficult to get settled with things.  The first thing being setting things right with my interests i.e Microcontroller kit installation and purchase of components. I need to find a shop where I am able to buy electronics stuff. It has been a tough time to solder my own USB PIC  programmer board. Well, things would get straight as the days pass by.

I always wanted to use/write a delay program which listens to my words. I had never been successful in this regard.

I downloaded a header file which was available over the internet. I had problems with my MPLAB software.

#include “delay.h”
#include <pic.h>
void main()
{
 TRISB = 0x00;
 PORTB = 0x00;
 
 while (1)
{
 PORTB = 0x00;
 DelayS(1);
 PORTB = 0XFF;
 DelayS(1);
}
}

Now, the problem with the code was that the hex file was mysteriously wrong.

Hex file Snapshot from winpic

Hex file Snapshot from winpic

Later, I used my age old code which I learnt from an Embedded Systems training centre:

#include “pic.h”
void delay_ms (int n);
void delay_us (int n);
void main()
{
 TRISB = 0x00;
 PORTB = 0x00;
 
 while (1)
{
 PORTB = 0x00;
delay_ms(1000);
 PORTB = 0XFF;
delay_ms(1000);
}
}
void delay_ms(int n)
{
 int i;
 for(i = 0; i<=n; i++)
{
delay_us(n);
}
}
void delay_us(int n)
{
 int j;
 for(j=0; j<=n; j++);
}

The result was the same.

I had a two line hex file. Hence, I concluded that something is wrong with MPLAB. I used MikroC for the same code.

Bingo! My code worked. My hex code was:

Led Blinking Mikro C

Now, I tried testing my code using the PIC16F877A Development board. It worked. My first relocation experiement is done. I don’t have a camera to upload the PIC right now. I shall do so in the near future

Advertisements

2 Responses to My experiments with PIC

  1. MGA says:

    Thank you for the information…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: