Continue to Site

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.

Can anyone please check my code? Is not working

Status
Not open for further replies.

zhiling0229

Member level 1
Joined
Jul 26, 2006
Messages
34
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,592
Hi guys,

I'm using PIC16F877A with CCS C compiler to develop my program. Initially I used portC and portD but I decided to change to portA and portB but after changing is not working? Can anyone point out the problem in my code:

struct lcd_pin_def
{
BOOLEAN cd; // A0 Command/Data BAR 1=command 0=data
BOOLEAN r_bar; // A1 Read bar active low
BOOLEAN w_bar; // A2 Write bar active low
BOOLEAN reset_bar; // A3 Reset active low
BOOLEAN unused1; // A4
BOOLEAN unused2; // A5
BOOLEAN unused3; // A6
BOOLEAN unused4; // A7
int data : 8; // PortB=Data bus
};
struct lcd_pin_def LCD;

#byte LCD = 0x05 // portA address on 16F877A

#use fast_io(D)

void main() {

setup_adc(ADC_OFF);

set_tris_a(0x00); // graphic lcd control lines all output
}

thanks
 

hi
Since port A has analog and digital mode you have to configure the Port A as analog or digital by setting the ADCON register. Moreover port A has only 6 bits.
 

Sorry guys,

I think i have misrepresented the information. Let me clarify. I'm a noob in C but I took the sample a driver program on the net. It uses port C and port D. I tested it, it was working fine but when I change it to port B and port A it did not work.

I just need to verify with you guys is my C correct since the only command I found in the help file to off the ADC is
setup_ADC(ADC_OFF);

Due to lack of documentation I need to verify is this command equivalent to:

changing the ADCON1 to 0x06 in a PIC16F877A or do i need more than just that C command?

thanks
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top