oz1lqb 0 Posted September 25, 2008 Report Share Posted September 25, 2008 (edited) Hi There.. first i am sorry my english is not the best.. i am having trouble wit this simple program. with a pic 16f877a it works. with a pic18f452 it compiles but returns only zero (adc_read) if i import it to oshonsoft simulator IT WORKS (maybe a problem with the simulator ?) with pic18f4523 it will not compile (would be nice with the 12bit adc) will not compile with pic16f886 will not compile with pic16f887 here is the program. --------------------------------------------------------------------------- ' ' commandas are: ' adc_init() ' adc_read() ' ' '***************************initiating ADC port starts ************************ sub adc_init() trisa = ( 00000001b ) trisa = ( 00000011b ) 'pin A0 is for analog input adcon1 = ( 10001110b ) 'setting for only AN0 and ref of vss and vdd, Fosc/8 adcon0 = ( 01000001b ) 'setting for channel AN0 and Fosc/8 for 4Mhz, start AD end sub '***************************initiating ADC port ends ************************** '****************** getting the value from the ADC port starts **************** function adc_read() as integer adcon0.2 = 1 call delay_ms(1) adcon0.2 = 0 call delay_ms(1) adc_read = adresh*256 adc_read=adc_read+adresl end function '****************** getting the value from the ADC port ends ****************** ------------------------------------------------------------------------------------------------------------------ all the best from oz1lqb / Claus Edited September 25, 2008 by oz1lqb Quote Link to post Share on other sites
Reynard 0 Posted September 25, 2008 Report Share Posted September 25, 2008 (edited) Have you told the compiler your clock frequency ? #pragma CLOCK_FREQ so it can calculate the correct delays. When you turn on the ADC module or change channel, you have to allow an aquisition time to allow the sampling capacitor to charge up to the input voltage before starting the conversion. Do not do 'adcon0.2 = 0'. The flag will reset itself to zero when conversion is complete so poll for it to happen before reading the result register. Writing a 0 may abort the conversion. Cheers Reynard Edited September 25, 2008 by Reynard Quote Link to post Share on other sites
oz1lqb 0 Posted September 25, 2008 Author Report Share Posted September 25, 2008 Have you told the compiler your clock frequency ? #pragma CLOCK_FREQ so it can calculate the correct delays. When you turn on the ADC module or change channel, you have to allow an aquisition time to allow the sampling capacitor to charge up to the input voltage before starting the conversion. Do not do 'adcon0.2 = 0'. The flag will reset itself to zero when conversion is complete so poll for it to happen before reading the result register. Writing a 0 may abort the conversion. Cheers Reynard ---------------------------------------------------------------------------- Hi Again.. yes i use the #pragrma CLOCK_FREQ 4000000.. i just removed "adcon0.2=0" still no change but with PIC16F452 it works in the real world but not ín the simulator that i can live with but what realy bothers me are the pic's that simply dont want to compile at all just spits out a long list of errors out.. Gretings from oz1lqb / Claus Quote Link to post Share on other sites
Reynard 0 Posted September 26, 2008 Report Share Posted September 26, 2008 I see what you mean about do not compile. It seems that the file "boostbasicpic16.bas" is missing a few chips. (Dave and Pavel take note!) You can try editing the file to include the missing chips. #ifdef _PIC16F887 #include <basic\PIC16F887.bas> #endif Rem _PIC16F887 Cheers Reynard Quote Link to post Share on other sites
oz1lqb 0 Posted September 26, 2008 Author Report Share Posted September 26, 2008 I see what you mean about do not compile. It seems that the file "boostbasicpic16.bas" is missing a few chips. (Dave and Pavel take note!) You can try editing the file to include the missing chips. #ifdef _PIC16F887 #include <basic\PIC16F887.bas> #endif Rem _PIC16F887 Cheers Reynard Hi Again.. thanks that fixed the problem with all the parts that did not compile. both the PIC16 & PIC18 parts.. still the problem with not simulating PIC18 Parts.. i dont know if the problem is that i am using my "old" plugins with picbasic ?. all the best oz1lqb / Claus Quote Link to post Share on other sites
Dave 0 Posted November 9, 2008 Report Share Posted November 9, 2008 oz1lqb, still the problem with not simulating PIC18 Parts..i dont know if the problem is that i am using my "old" plugins with picbasic ?. all the best oz1lqb / Claus Please check IDE user manual Appendix A: SourceBoost IDE Simulator features and limitations. Regards Dave Quote Link to post Share on other sites
oz1lqb 0 Posted November 9, 2008 Author Report Share Posted November 9, 2008 (edited) oz1lqb,still the problem with not simulating PIC18 Parts..i dont know if the problem is that i am using my "old" plugins with picbasic ?. all the best oz1lqb / Claus Please check IDE user manual Appendix A: SourceBoost IDE Simulator features and limitations. Regards Dave Hi .. the problem with the plugins is ok i know i should buy a licence for the new plugins.. but what iretates me is the missing pic's..(those that will not compile) i can "fix" the problem as described by another here but i think i am not the only one to have that problem.. all the best from oz1lqb / claus Edited November 9, 2008 by oz1lqb Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.