CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

A/D Operations in 3.158

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Dave Yeatman
Guest







A/D Operations in 3.158
PostPosted: Sat May 24, 2003 7:21 pm     Reply with quote

Am I missing something here? I have included the LST lines for READ_ADC operations I am doing in a CASE statement. It appears that it sometimes accesses the wronmg registers, sometimes sets the GO bit and sometimes test the DONE bit but not every time.

Anyone seen this? I sent this to CCS also....

018A: INCF 43,F
.................... switch (sensor_select)
018B: MOVF 42,W
018C: ADDLW FB
018D: BTFSC 03.0
018E: GOTO 22F
018F: ADDLW 05
0190: GOTO 2E6
.................... {
.................... case 0: {// read the
.................... Light_lvl_In=read_adc(0);
0191: CLRF 7A
0192: MOVWF 53
0193: MOVF 7A,W
0194: MOVWF 54
.................... // we have to convert the voltage value here
.................... break;
0195: GOTO 22F
.................... }
.................... case 1: {
.................... Humidity_In= read_adc(1);
0196: BSF 1F.2
0197: CLRF 7A
0198: MOVWF 4F
0199: MOVF 7A,W
019A: MOVWF 50
.................... // we have to convert the voltage value here
.................... break;
019B: GOTO 22F
.................... }
.................... case 2: {
.................... Moisture_In= read_adc(2);
019C: BTFSC 1F.2
019D: GOTO 19C
019E: CLRF 7A
019F: MOVWF 51
01A0: MOVF 7A,W
01A1: MOVWF 52
.................... // we have to convert the voltage value here
.................... break;
01A2: GOTO 22F
.................... }
.................... case 3: {
.................... temp1= read_adc(3);
01A3: BSF 1F.2
01A4: BTFSC 1F.2
01A5: GOTO 1A4
01A6: MOVWF 2B
.................... // we will have to convert the voltage input to N,S,E,W etc. (256/16 pts = 16 counts per point)
.................... if ((temp1 > 248) || (temp1 < 8)) // equate voltage to direction
01A7: MOVF 2B,W
01A8: SUBLW F8
01A9: BTFSS 03.0
01AA: GOTO 1AF
01AB: MOVF 2B,W
01AC: SUBLW 07
01AD: BTFSS 03.0
01AE: GOTO 1B3
.................... wind_dir=1; // this is NORTH
01AF: CLRF 4E
01B0: MOVLW 01
01B1: MOVWF 4D
.................... else
01B2: GOTO 22A
.................... if (temp1 > 232)
01B3: MOVF 2B,W
01B4: SUBLW E8
01B5: BTFSC 03.0
01B6: GOTO 1BB
.................... wind_dir=16; // this is NNW
01B7: CLRF 4E
01B8: MOVLW 10
01B9: MOVWF 4D
.................... else
01BA: GOTO 22A
.................... if (temp1 > 216)
01BB: MOVF 2B,W
01BC: SUBLW D8
01BD: BTFSC 03.0
01BE: GOTO 1C3
.................... wind_dir=15; // this must be NW
01BF: CLRF 4E
01C0: MOVLW 0F
01C1: MOVWF 4D
.................... else
01C2: GOTO 22A
.................... if (temp1 > 200)
01C3: MOVF 2B,W
01C4: SUBLW C8
01C5: BTFSC 03.0
01C6: GOTO 1CB
.................... wind_dir=14; // this must be WNW
01C7: CLRF 4E
01C8: MOVLW 0E
01C9: MOVWF 4D
.................... else
01CA: GOTO 22A
.................... if (temp1 > 184)
01CB: MOVF 2B,W
01CC: SUBLW B8
01CD: BTFSC 03.0
01CE: GOTO 1D3
.................... wind_dir=13; // this must be West
01CF: CLRF 4E
01D0: MOVLW 0D
01D1: MOVWF 4D
.................... else
01D2: GOTO 22A
.................... if (temp1 > 168)
01D3: MOVF 2B,W
01D4: SUBLW A8
01D5: BTFSC 03.0
01D6: GOTO 1DB
.................... wind_dir=12; // this must be WSW
01D7: CLRF 4E
01D8: MOVLW 0C
01D9: MOVWF 4D
.................... else
01DA: GOTO 22A
.................... if (temp1 > 152)
01DB: MOVF 2B,W
01DC: SUBLW 98
01DD: BTFSC 03.0
01DE: GOTO 1E3
.................... wind_dir=11; // this must be SW
01DF: CLRF 4E
01E0: MOVLW 0B
01E1: MOVWF 4D
.................... else
01E2: GOTO 22A
.................... if (temp1 > 136)
01E3: MOVF 2B,W
01E4: SUBLW 88
01E5: BTFSC 03.0
01E6: GOTO 1EB
.................... wind_dir=10; // this must be SSW
01E7: CLRF 4E
01E8: MOVLW 0A
01E9: MOVWF 4D
.................... else
01EA: GOTO 22A
.................... if (temp1 > 120)
01EB: MOVF 2B,W
01EC: SUBLW 78
01ED: BTFSC 03.0
01EE: GOTO 1F3
.................... wind_dir=9; // this must be South
01EF: CLRF 4E
01F0: MOVLW 09
01F1: MOVWF 4D
.................... else
01F2: GOTO 22A
.................... if (temp1 > 104)
01F3: MOVF 2B,W
01F4: SUBLW 68
01F5: BTFSC 03.0
01F6: GOTO 1FB
.................... wind_dir=8; // this must be SSE
01F7: CLRF 4E
01F8: MOVLW 08
01F9: MOVWF 4D
.................... else
01FA: GOTO 22A
.................... if (temp1 > 88)
01FB: MOVF 2B,W
01FC: SUBLW 58
01FD: BTFSC 03.0
01FE: GOTO 203
.................... wind_dir=7; // this must be SE
01FF: CLRF 4E
0200: MOVLW 07
0201: MOVWF 4D
.................... else
0202: GOTO 22A
.................... if (temp1 > 72)
0203: MOVF 2B,W
0204: SUBLW 48
0205: BTFSC 03.0
0206: GOTO 20B
.................... wind_dir=6; // this must be ESE
0207: CLRF 4E
0208: MOVLW 06
0209: MOVWF 4D
.................... else
020A: GOTO 22A
.................... if (temp1 > 56)
020B: MOVF 2B,W
020C: SUBLW 38
020D: BTFSC 03.0
020E: GOTO 213
.................... wind_dir=5; // this must be East
020F: CLRF 4E
0210: MOVLW 05
0211: MOVWF 4D
.................... else
0212: GOTO 22A
.................... if (temp1 > 40)
0213: MOVF 2B,W
0214: SUBLW 28
0215: BTFSC 03.0
0216: GOTO 21B
.................... wind_dir=4; // this must be ENE
0217: CLRF 4E
0218: MOVLW 04
0219: MOVWF 4D
.................... else
021A: GOTO 22A
.................... if (temp1 > 24)
021B: MOVF 2B,W
021C: SUBLW 18
021D: BTFSC 03.0
021E: GOTO 223
.................... wind_dir=3; // this must be NE
021F: CLRF 4E
0220: MOVLW 03
0221: MOVWF 4D
.................... else
0222: GOTO 22A
.................... if (temp1 > 8)
0223: MOVF 2B,W
0224: SUBLW 08
0225: BTFSC 03.0
0226: GOTO 22A
.................... wind_dir=2; // this must be NNE
0227: CLRF 4E
0228: MOVLW 02
0229: MOVWF 4D
.................... // ************ End of Wind conversion test ************
....................
.................... break; // end of case 3
022A: GOTO 22F
.................... }
.................... case 4: {
.................... Pressure_In= read_adc(4);
022B: MOVF 1E,W
022C: CLRF 4C
022D: MOVWF 4B
.................... //
.................... // we have to convert the voltage value here
.................... // update_sensors=false; // last one so kill update flag till next minute
.................... break;
022E: GOTO 22F
.................... }
.................... // default:
.................... // {
.................... // sensor_select=0;
.................... // }
.................... }

___________________________
This message was ported from CCS's old forum
Original Post ID: 144514739
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: A/D Operations in 3.158
PostPosted: Sat May 24, 2003 10:27 pm     Reply with quote

:=.................... case 0: {
:=.................... Light_lvl_In=read_adc(0);
:=.................... case 1: {
:=.................... Humidity_In= read_adc(1);
:=.................... case 2: {
:=.................... Moisture_In= read_adc(2);
:=.................... temp1= read_adc(3);
-----------------------------------------------------------

In the numbers 0,1,2,3 above, are you trying to set the A/D
channel ? That is done with the set_adc_channel(n) function.
The parameter for read_adc(n) is for the mode, which can be
one of these three settings:

// Constants used in READ_ADC() are:
#define ADC_START_AND_READ 7 // This is the default if nothing is specified
#define ADC_START_ONLY 1
#define ADC_READ_ONLY 6

(This is from 16F877.h)
___________________________
This message was ported from CCS's old forum
Original Post ID: 144514740
Dave Yeatman
Guest







Re: A/D Operations in 3.158
PostPosted: Sun May 25, 2003 7:55 am     Reply with quote

:=:=.................... case 0: {
:=:=.................... Light_lvl_In=read_adc(0);
:=:=.................... case 1: {
:=:=.................... Humidity_In= read_adc(1);
:=:=.................... case 2: {
:=:=.................... Moisture_In= read_adc(2);
:=:=.................... temp1= read_adc(3);
:=-----------------------------------------------------------
:=
:=In the numbers 0,1,2,3 above, are you trying to set the A/D
:=channel ? That is done with the set_adc_channel(n) function.
:=The parameter for read_adc(n) is for the mode, which can be
:=one of these three settings:
:=
:=// Constants used in READ_ADC() are:
:=#define ADC_START_AND_READ 7 // This is the default if nothing is specified
:=#define ADC_START_ONLY 1
:=#define ADC_READ_ONLY 6
:=
:=(This is from 16F877.h)

Yes, I set the channel in another routine to make sure I have plenty of time for it to settle. The Read_ADC parameter was a stupid oversight on my part, that may fix things...Thanks!
___________________________
This message was ported from CCS's old forum
Original Post ID: 144514744
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group