Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

help me with a pic16877a

Status
Not open for further replies.

angelomary

Newbie level 2
Joined
Dec 5, 2009
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
jordan
Activity points
1,306
Hello all:
am working in my final year project, i decide to use a pic16877a ,output to a buzzers & 8*8 Dot matrix, i try to implement my design using a protous simulator but there is no output while figure indicate there is a input so is my code wrong anyone know plz , my code listed below
program locator2
void main()
{char oldstate1 = 0;
char oldstate2 = 0;
char oldstate3 = 0;
char oldstate4 = 0;
char i=0;
trisa=0b00001111;
trisb=0x00;
trisc=0x00;
trisd=0x00;
trise=0b000;
porte=0;
portc=0;
portb=0;


do {
if (Button(&PORTA, 0, 1, 1)) // detect logical one on RA0 pin
oldstate1 = 1;
if (oldstate1 && Button(&PORTA, 0, 1, 0)) // detect one-to-zero transition on RA0 pin
{
porte.f0 = ~ porte.f0; // negates value on RE0
oldstate1 = 0;
}
} while(1); // endless loop


do {
if (Button(&PORTA, 1, 1, 1)) // detect logical one on RA1 pin
oldstate2 = 1;
if (oldstate2 && Button(&PORTA, 1, 1, 0)) // detect one-to-zero transition on RA1 pin
{porte.f1 = ~ porte.f1; // negates value on RE0
oldstate2 = 0;
}
} while(1); // endless loop



do {
if (Button(&porta, 2, 1, 1)) // detect logical one on RA2 pin
oldstate3 = 1;
if (oldstate3 && Button(&porta, 2, 1, 0)) // detect one-to-zero transition on RA2 pin
{
if(i=0) {
portc=0b11001100;
portb=0b01010110 ;
i=i+1;
}

if(i=1) {
portc=0b01001100;
portb=0b01011110;
i=i+1;
}

if(i=2) {
portc=0b00001100;
portb=0b11011110;
i=i+1;
}

if(i=3) {
portc=0b01100100;
portb=0b11010110;
i=i+1;

}

if(i=4) {
portc=0b01011100;
portb=0b11000110;
i=0;
}

oldstate3 = 0;
}
}while(1); // endless loop



do {
if (Button(&PORTA, 3, 1, 1)) // detect logical one on RA3 pin
oldstate4 = 1;
if (oldstate4 && Button(&PORTA, 3, 1, 0)) // detect one-to-zero transition on RA3 pin
{ if(i=0) {
portc=0b01001100;
portb=0b11100111;
i=i+1;
}

if(i=1) {
portc=0b01010100;
portb=0b11110110;
i=i+1;
}

if(i=2) {
portc=0b01101101;
portb=0b11010100;
i=i+1;
}

if(i=3) {
portc=0b01011100;
portb=0b11011010;
i=i+1;

}

if(i=4) {
portc=0b01101110;
portb=0b10010110;
i=0;
}

oldstate4 = 0;
}
}while(1); // endless loop

}

Added after 4 minutes:

also here is my circuit
 

matbob

Full Member level 2
Joined
May 15, 2008
Messages
128
Helped
26
Reputation
52
Reaction score
12
Trophy points
1,298
Location
KERALA
Activity points
2,061
Hi angelomary,


I don't know whether there is anything wrong in your code. In Proteus simulation don't use those 'analog' resistors for pulldown or pullup purpose. You can find a model named 'PULLUP' in the parts list. It is a digital model of a resistor and it can make simulation (use only in digital circuits) faster and also ensures the correct logic states.
 

angelomary

Newbie level 2
Joined
Dec 5, 2009
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
jordan
Activity points
1,306
thanks for your replay i tried to put a pullup resistor instead but no result even the switch dosent make a logic 1 to the pic while in analogue it was put a logic 1
 

matbob

Full Member level 2
Joined
May 15, 2008
Messages
128
Helped
26
Reputation
52
Reaction score
12
Trophy points
1,298
Location
KERALA
Activity points
2,061
Hi angelomary,

I think I got it! You haven't set the port A pins as digital. By default, after power on reset, all the pins which can be used as ADC inputs are configured as analog inputs. To make all ADC pins digital, set 'ADCON1=0x7' during initialisation of port pins. Please refer 'ANALOG-TO-DIGITAL CONVERTER (A/D) MODULE' section in PIC16F877A datasheet for more details.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top