Menu

all about electronic and microcontrollers

Sunday, October 17, 2010

Lesson nr.01-Hello everybody

Hardware setup:
In the first experiment that we are going to do, with PIC16F628A, we will show how to set M.C.U (MicroController Unit) to make all ports output (in 1 logic, meaning in this case 5vcc).
The output will be displayed on L.E.Ds, connected to PORTA and PORTB. Series resistors with L.E.Ds are able to limit the current through the LED to meet the data catalog (max. 20 ~ 25mA with a minimum voltage of 1.8 V  to open junction P.N).
Below you can find a video which showing a live demonstration of the entire circuit.



Circuit Diagram:
For those who want to build it on their own breadboard or other platform, here is the electronic scheme built in Eagle Cad, free version:

 

Software:
Here is the C program written for MikroC PRO for PIC 2010 (version v4.15).
/*
'*******************************************************************************
'  Lesson nr.01:
'          Hello everybody
'  Written by:
'          Aureliu Raducu Macovei, 2010.
'  Description:
'          In this experiment we will show how to set MCU to make all ports output 
'          (in 1 logic).
'          The output will be displayed on LEDs, connected to PORTA and PORTB.
'  Test configuration:
'    MCU:                        PIC16F628A
'    Test.Board:                 WB-106 Breadboard 2420 dots
'    SW:                         MikroC PRO for PIC 2010 (version v4.15)
'  Configuration Word
'    Oscillator:                 INTOSC:I/O on RA.6, I/O on RA.7
'    Watchdog Timer:             OFF
'    Power up Timer:             Disabled
'    Master Clear Enable:        Enabled
'    Browun Out Detect:          Enabled
'    Low Voltage Program:        Disabled
'    Data EE Read Protect:       Disabled
'    Code Protect:               OFF
'*******************************************************************************
*/
void main()                 //MAIN;
{
 CMCON |=7;                 //TURN OFF ANALOGUE COMPARATOR AND MAKE PORTA TO DIGITAL I/O;
 TRISA = 0x00;              //SET PORTA TO BE OUTPUT;
 TRISB = 0x00;              //SET PORTB TO BE OUTPUT;
 PORTA = 0xFF;              //TURN ON LEDs ON PORTA;
 PORTB = 0xFF;              //TURN ON LEDs ON PORTB;
}                           //END.

6 comments:

  1. Why can not I use PORTA as input?

    ReplyDelete
  2. Hello, mario
    please describe your issues, what kind of microcontroller you use?

    ReplyDelete
  3. Thank for the code! its really helpful. very clean and neat explanation

    ReplyDelete
  4. Hey how are you. I found your blog through Google and I just wanted to say that I think your writing is simply stunning! Thanks for providing this content for free.Nice

    electronic display boards india

    ReplyDelete
  5. how to turn off analogue comparator if i changed the pic from 16f628to 18f46k80?

    ReplyDelete

If you do not understand something, or if you make some aplication helped by this blog, let me know.