Help with PIC16f877a-i/p

Thread Starter

Oretega

Joined Jun 4, 2008
2
I have made a script to Power up 2 7 segment displays (common anode)
with
Port A to control the common anode part using a 2N3906 pnp BJT.
Port B power up the cathode part of the 7 seg.
Is this script correct? Its my first time programming one, and none of the lights light up. I am having a headache now. lolz.

;*******************************;
; Pressure Sensor Program ;
; Oretega 6/4/2008 ;
;*******************************;
list p=16F877A
#include p16F877A.inc
; The start of the main program
Main:
__CONFIG _CP_OFF & _WDT_OFF & _HS_OSC & _LVP_OFF & _BODEN_OFF
org 0
PORTA equ 00h
PORTB equ FFh
END
 

mik3

Joined Feb 4, 2008
4,843
I have made a script to Power up 2 7 segment displays (common anode)
with
Port A to control the common anode part using a 2N3906 pnp BJT.
Port B power up the cathode part of the 7 seg.
Is this script correct? Its my first time programming one, and none of the lights light up. I am having a headache now. lolz.

;*******************************;
; Pressure Sensor Program ;
; Oretega 6/4/2008 ;
;*******************************;
list p=16F877A
#include p16F877A.inc
; The start of the main program
Main:
__CONFIG _CP_OFF & _WDT_OFF & _HS_OSC & _LVP_OFF & _BODEN_OFF
org 0
PORTA equ 00h
PORTB equ FFh
END
First you have to set the oscillator frequency and setup your timers. Then set which I/O you want to be inputs and which to be outputs. Also you have to use a while condition like this
while (true)
{
your code
}

to have an infinite loop of operation.

Look at this website http://www1.ceit.es/asignaturas/robots/datasheets/CCS.pdf

It says the instructions to program in C language

Here is a part of the beginning of a program of mine in C:

#include <16f819.h>

#fuses NOWDT, INTRC_IO, NOPUT, NOMCLR, NOBROWNOUT, NOLVP, NOCPD, NOWRT, NODEBUG, NOPROTECT

#use fast_io(A)
#use fast_io(B)

void main()
{
setup_oscillator(OSC_8MHZ);

set_TRIS_B(0b00000000); //determine which pins are inputs and which are outputs
set_TRIS_A(0b00111111);

SETUP_TIMER_0(RTCC_DIV_128);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);

while (true)
{
your code
}
 

Thread Starter

Oretega

Joined Jun 4, 2008
2
I have learned c++ in college 2 years ago, quite blurry in my mind now. But think it will be easier than assembly language. Can teach me how to use it with mplab?
 
Top