Stanley Lee schrieb: > Hi, > > Here's more news about the progress so far. I have added Jan's code on > the initialization in the initialization.c file. My quesiton on the > initialization is the fact that I'm unsure of how I should deal with the > first parameter of adc_open function. I have typed in my guess after > looking at adc.h, and indicated my doubts on my initialization.c.
See my patch (link was in the last mail) for the pic18fXX50 devices. The adc_open, adc_setchanel and adc_busy functions dont work for pic18fXXXX. You need to apply the patch,edit the #if defined and recompile/install sdcc to make the adc library work for pic18fXXXX devices. All #if defined should look like: if defined(pic18f2455) || defined (pic18f2550) \ || defined(pic18f4455) || defined (pic18f4550) \\ || defined(pic18f2525) || defined (pic18f2620) \\ || defined(pic18f4525) || defined (pic18f4620) Remember to do this in adcsetch.c, adcopen.c, adcbusy.c and adc.h Hopefully this patch will someday be part of sdcc. > > I have a separate source file (adcisr.c) that deals with the a/d > conversion ISR. I have basically incorporated Jan's code, except I have > modified it to work for one a/d channel (AN0) to free up the other > channels as I only need to sample one channel. I have also an accessor > function that allows me to access the a/d channel input values from any > other source file of my project. One advice here: You need to disable the adc_int during your adcval function. If you dont then there is a slight chance that your read garbage when the interrupt is triggered during the function call. > However, when I tested my code using > the PWM toggling method. I don't seem to see a PWM output at the > corresponding port B pin no matter how I vary the voltage input from > adjusting a potentiometer. I infer that there is something wrong with > the structure of my project as I have limited experience working with > multiple source files (I don't want to squeeze everything into a single > main.c file either). This is mainly because of the missing patch. Apply it as described above and retry it pls. > > Any insights would be much appreciated. if your really need pwm pls use the pic pwm modul. jan ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user