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.

analog to digital conversion with pic18f4550

Status
Not open for further replies.

eanema

Member level 2
Joined
Sep 30, 2009
Messages
43
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,288
Activity points
1,740
Hello All,

I am using the "USB Device - CDC - Basic Demo" from the new usb firmware package from microchip. I have modified the UserInit() function by adding:

TRISA=TRISA|0x0f;
ADCON0=0x01;
ADCON1=0x0b;
ADCON2=0x3e;
USB_DataCount = 0;

and the ProcessIO() function by replacing the unnecessary code with:
if(sw2 == 0) {
//start AD conversion
ADCON0 = ADCON0|0x02;
mLED_4_On();
}

if (ADCON0 & 0x02 == 0) {
ServiceAD();
mLED_4_Off();
}

This code will test a switch and then start the AD conversion and turn on led 4 when the switch is thrown.

it then tests to see if the conversion is finished, if it is it will turn off the light.

My problem is that i can't seem to get the conversion to finish. IE the light never turns off.

Any ideas what I am doing wrong would be very helpful

Thanks
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top