Some basic stuff . . .

A few days ago I posted an article about the DEVCC ProtoShield, so today I thought lets do the following:

  1. Show some basic things about the shield
  2. Get a simple project working

The hello world project is severely overdone, but it is an important project and something you will use over and over again. You will find that when you get a new board, a new device or whatever the new is, a flashing LED will answer allot of questions. I have listed a few below:

  1. Did the device power up ?
  2. Have I configured the device correctly?
  3. Is the board working or faulty?
  4. Does my programmer / bootloader actually work?
  5. And there are a few more . . . we will skip for now

If you have used PICs before or even know a little about them you know that to get your device working you configure

  1. The TRIS register or direction register
    1. 1 for input
    2. 0 for output
  2. You set that register for either input or output
    1. Output: you drive a device / protocol etc
    2. Input: you process data in (data is the more pragmatic way of referring to what you get in)
  3. Shared Peripherals: In the effort to compact more into a device, devices share peripherals per pin or pins. This can be a nightmare depending on what you are trying to do but usually a quick scout through the manual and you have your answer.Note: Key point here is if you do not switch the shared peripheral off or disable it, it will interfere with your code.
  4. After the above you flash the device and away you go

The ‘Basic stuff’ code is below and I won’t say self explanatory but if you can code or know a little you should be able to read it easy enough. It’s written in and at the bottom you will see the void main() function. This is your basic function and also the main loop of your code. From there I have a call to the Startup() function; this just configures the device. From there the Flash() method which set PORTB.B1 or the second PIN of PORT B high and low; toggling. All this is called from the infinite loop while(1) {}. Provided there is power it will flash.

/*
Some Basic Stuff
*/
StartUp(){

TRISA = 0xFF;
TRISB = 0xFC;
ANSELB = 0x0;
PORTB.B1 = 1;
}

Flash(){

PORTB.B0 = PORTB.B0^1;
PORTB.B1 = PORTB.B1^1;
Delay_ms(1000);
}

void main() {

StartUp();

while(1){
Flash();
}
}

How to connect the DEVCC PCB ?

You connect the PIN RB1 to 4 on the header. And your LED should start to flash. See the image below and it will help clarify the connections.

Basic Stuff

You may have noticed that the base PCB is blue and that’s because to illustrate that any of the DEVCC boards can be used I have connected it to a DEVCC V18 and a PIC16F1847 is powering your LED.

Resources : Some basic stuff Project code (MikroC required)

Done this already? Well then stay posted and I will be uploading the next article shortly.

[E]