Paul James E. wrote: > A question about the 10 bit AD on an F877. Referring to the code > snippet below, looking at the line indicated ( by **--->), can anyone > explain why when this reads 'bsf STATUS,RP0', the program hangs > apparently at that line. If we change it to read 'bcf STATUS,RP0', > the program don't hang, I'm not going to check whether you are manually trying to set the right banks. This sort of thing should be left to the assembler. It knows the exact address of each SFR and can therefore emit the appropriate code to switch to the right bank. At the very least use BANKSEL so that people trying to help you don't get distracted by bank setting issues. A better answer is the DBANKIF and related macros in STD.INS.ASPIC at http://www.embedinc.com/pic. > RdVrp ; read ASIC pos ref voltage > errorlevel -302 > bcf STATUS, RP0 ;bank 0 > bcf STATUS, RP1 Should be BANSEL ADCON0, or DBANKIF ADCON0, at least when you're asking others to look at your code (see above). Again, I'm not going to verify that you really want bank 0 here, although this is where the bug is more times than not. > movlw B'01001001' ;Fosc/8, A/D chan 1, A/D > movwf ADCON0 > bsf ADCON0, GO You didn't leave anywhere near enough acquisition time here. > movlw D'1' > call Wait Does WAIT effect the bank setting? In general you should invalidate your bank assumptions after a call. > VrpWait > btfsc ADCON0, GO You are assuming a specific bank here, but it's not obvious the bank settings aren't completely trashed at this point. > goto VrpWait > > bcf STATUS, RP0 And RP1? > movf ADRESH, W > movwf AccaH And the bank of ACCAH > **---> bsf STATUS,RP0 ; goto page 1 I seriously doubt this instruction is hanging the machine. How did you reach that conclusion? > Does anyone have any ideas to try that I haven't mentioned? You need to clean up your banking act. Other issues are a waste of time until that is done. ***************************************************************** Embed Inc, embedded system specialists in Littleton Massachusetts (978) 742-9014, http://www.embedinc.com -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads