• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

newbie needs help...in a project

Status
Not open for further replies.

kingsden

New Member
i am doing a program for temperature control (temp max is 40deg)....if it exceeds start a fan at 80% duty cycle......

i am getting this error when i build it;;;
Error[128] C:\USERS\PRAVEEN\MPLAB\GDADC.ASM 51 : Missing argument(s)

when i click it is pointing to GOTO PWM80 line in the program......

i am using mplab ide v 8.20.....don know wat code tags are...
LIST P=16F877 ; XTAL 20 MHZ
Stimulus: Synchronous stimulus applied successfully.
CORE-W0014: Halted due to PC incrementing over the Maximum PC address and wrapping back to Zero
CORE-W0014: Halted due to PC incrementing over the Maximum PC address and wrapping back to Zero
CORE-W0014: Halted due to PC incrementing over the Maximum PC address and wrapping back to Zero
Stimulus: Synchronous stimulus applied successfully.




#include<p16f877a.inc>

#DEFINE LOOP ; if i did not use this it was givin an error symbol nt previously defined
#DEFINE PWM80
#DEFINE PWM20
#DEFINE PWM1

ORG 0X00

REG1 EQU 0X29
RES1 EQU 0X30
RES2 EQU 0X31

MOVLW 0XFF
BANKSEL TRISA
MOVWF TRISA ;PORTA I/P

BANKSEL PIE1
BCF PIE1,ADIF ;DISABLE ADC INTERRUPT

BANKSEL ADCON0
MOVLW 0XC1
MOVWF ADCON0 ; RA0 AS ADC PORT

MOVLW 0X80
BANKSEL ADCON1
MOVWF ADCON1 ; PORTA FOR ADC CHANNEL..RIGHT JUSTIFICATION




;SUBROUTINE GETADC===============================


LOOP BANKSEL ADCON0
BSF ADCON0,GO ; start a/d conversion

ADCLOOP BTFSC ADCON0,GO ;WAIT FOR CONVERSION TO FINISH
GOTO ADCLOOP

BCF PIR1,ADIF ; CLEAR CONVERSION COMPLETE FLAG

;COMPARISON WITH THE SETPOINT====================

MOVF ADRESL,W

SUBLW .83 ;FOR SETPOINT 40 DEGREES
MOVWF RES1
BTFSC RES1,7 ; CHECK WHETHER THE MSB IS 1 ,IF SO IT MEANS
; THAT TEMP>40 HENCE CALL 80% PWMDUTYCYCLE
GOTO PWM80

SUBLW .73 ; FOR 35 DEGREES
MOVWF RES2
BTFSC RES2,7 ;CHECK WHETHER THE MSB IS 1 ,IF SO IT MEANS
; THAT TEMP>35 HENCE CALL 20% PWMDUTYCYCLE
GOTO PWM20

GOTO PWM1 ; IF THE ABOVE TWO CONDS DOES NT SATISFY CALL
; 1% PWMDUTY CYCLE


;PWMCYCLES==========================================


PWM80 BANKSEL PR2
MOVLW 0X31
MOVWF PR2 ; FREQUENCY IS SET FOR 10MICROSECS

BCF STATUS,RP0
BCF STATUS,RP1
MOVLW 0X48
MOVWF CCPR1L
MOVLW 0X0C
MOVWF CCP1CON

;TRISC Setting for output
BANKSEL TRISC
BCF TRISC, PWM1

BANKSEL T2CON
;TMR2 Prescale selection(PRESCALE TO 1:16 AND POSTSCLE TO 1:1) and TMR2 Turn On
MOVLW 0X07
MOVWF T2CON

GOTO LOOP


PWM20 BANKSEL PR2 ;FOR 20%DUTYCYCLE
MOVLW 0X31
MOVWF PR2 ; FREQUENCY IS SET FOR 10MICROSECS

BCF STATUS,RP0
BCF STATUS,RP1
MOVLW 0X0A
MOVWF CCPR1L
MOVLW 0X0C
MOVWF CCP1CON

;TRISC Setting for output
BANKSEL TRISC
BCF TRISC, PWM1

BANKSEL T2CON
;TMR2 Prescale selection(PRESCALE TO 1:16 AND POSTSCLE TO 1:1) and TMR2 Turn On
MOVLW 0x07
MOVWF T2CON

GOTO LOOP

PWM1 BANKSEL PR2 ; FOR 1% DUTYCYCLE
MOVLW 0X31
MOVWF PR2 ; FREQUENCY IS SET FOR 10MICROSECS

BCF STATUS,RP0
BCF STATUS,RP1

MOVLW 0X00
MOVWF CCPR1L
MOVLW 0X2C
MOVWF CCP1CON

;TRISC Setting for output
BANKSEL TRISC
BCF TRISC, PWM1

BANKSEL T2CON
;TMR2 Prescale selection(PRESCALE TO 1:16 AND POSTSCLE TO 1:1) and TMR2 Turn On
MOVLW 0x07
MOVWF T2CON

GOTO LOOP

END


pls help me out...........how to solve this....
 
Last edited:

ericgibbs

Well-Known Member
Most Helpful Member
As Bill says,, tidy courtesy of Pommie.


Code:
#include<p16f877a.inc>  

#DEFINE	LOOP			; if i did not use this it was givin an error symbol nt previously defined
#DEFINE	PWM80
#DEFINE	PWM20
#DEFINE	PWM1

	org	0X00

REG1	equ	0X29
RES1	equ	0X30
RES2	equ	0X31

	movlw	0XFF
	banksel	TRISA
	movwf	TRISA		;PORTA I/P

	banksel	PIE1
	bcf	PIE1,ADIF	;DISABLE ADC INTERRUPT

	banksel	ADCON0
	movlw	0XC1
	movwf	ADCON0		; RA0 AS ADC PORT

	movlw	0X80
	banksel	ADCON1
	movwf	ADCON1		; PORTA FOR ADC CHANNEL..RIGHT JUSTIFICATION




;SUBROUTINE GETADC===============================  


LOOP	banksel	ADCON0
	bsf	ADCON0,GO	; start a/d conversion

ADCLOOP	btfsc	ADCON0,GO	;WAIT FOR CONVERSION TO FINISH
	goto	ADCLOOP

	bcf	PIR1,ADIF	; CLEAR CONVERSION COMPLETE FLAG

;COMPARISON WITH THE SETPOINT====================  

	movf	ADRESL,W

	sublw	.83		;FOR SETPOINT 40 DEGREES
	movwf	RES1
	btfsc	RES1,7		; CHECK WHETHER THE MSB IS 1 ,IF SO IT MEANS
; THAT TEMP>40 HENCE CALL 80% PWMDUTYCYCLE  
	goto	PWM80

	sublw	.73		; FOR 35 DEGREES
	movwf	RES2
	btfsc	RES2,7		;CHECK WHETHER THE MSB IS 1 ,IF SO IT MEANS
; THAT TEMP>35 HENCE CALL 20% PWMDUTYCYCLE  
	goto	PWM20

	goto	PWM1		; IF THE ABOVE TWO CONDS DOES NT SATISFY CALL
; 1% PWMDUTY CYCLE  


;PWMCYCLES======================================== ==  


PWM80	banksel	PR2
	movlw	0X31
	movwf	PR2		; FREQUENCY IS SET FOR 10MICROSECS

	bcf	STATUS,RP0
	bcf	STATUS,RP1
	movlw	0X48
	movwf	CCPR1L
	movlw	0X0C
	movwf	CCP1CON

;TRISC Setting for output  
	banksel	TRISC
	bcf	TRISC, PWM1

	banksel	T2CON
;TMR2 Prescale selection(PRESCALE TO 1:16 AND POSTSCLE TO 1:1) and TMR2 Turn On  
	movlw	0X07
	movwf	T2CON

	goto	LOOP


PWM20	banksel	PR2		;FOR 20%DUTYCYCLE
	movlw	0X31
	movwf	PR2		; FREQUENCY IS SET FOR 10MICROSECS

	bcf	STATUS,RP0
	bcf	STATUS,RP1
	movlw	0X0A
	movwf	CCPR1L
	movlw	0X0C
	movwf	CCP1CON

;TRISC Setting for output  
	banksel	TRISC
	bcf	TRISC, PWM1

	banksel	T2CON
;TMR2 Prescale selection(PRESCALE TO 1:16 AND POSTSCLE TO 1:1) and TMR2 Turn On  
	movlw	0x07
	movwf	T2CON

	goto	LOOP

PWM1	banksel	PR2		; FOR 1% DUTYCYCLE
	movlw	0X31
	movwf	PR2		; FREQUENCY IS SET FOR 10MICROSECS

	bcf	STATUS,RP0
	bcf	STATUS,RP1

	movlw	0X00
	movwf	CCPR1L
	movlw	0X2C
	movwf	CCP1CON

;TRISC Setting for output  
	banksel	TRISC
	bcf	TRISC, PWM1

	banksel	T2CON
;TMR2 Prescale selection(PRESCALE TO 1:16 AND POSTSCLE TO 1:1) and TMR2 Turn On  
	movlw	0x07
	movwf	T2CON

	goto	LOOP

	end
 
Last edited:

ericgibbs

Well-Known Member
Most Helpful Member
thx ericgibbs for makin it look good

hi,
Try this, it now only 3 out of range errors, marked by ;++++++++++++

It assembles , but correct these errors.!

Clue: You are using PWM1 as label.!

look at the added header code area;

Code:
	list p=16f877a
	#include <p16f877a.inc>
	radix dec
                errorlevel -302, -207



;#DEFINE	LOOP			; if i did not use this it was givin an error symbol nt previously defined
;#DEFINE	PWM80
;#DEFINE	PWM20
;#DEFINE	PWM1


REG1	equ	0X29
RES1	equ	0X30
RES2	equ	0X31

	org	0X00


	movlw	0XFF
	banksel	TRISA
	movwf	TRISA		;PORTA I/P

	banksel	PIE1
	bcf	PIE1,ADIF	;DISABLE ADC INTERRUPT

	banksel	ADCON0
	movlw	0XC1
	movwf	ADCON0		; RA0 AS ADC PORT

	movlw	0X80
	banksel	ADCON1
	movwf	ADCON1		; PORTA FOR ADC CHANNEL..RIGHT JUSTIFICATION


;SUBROUTINE GETADC===============================  


LOOP:
	banksel	ADCON0
	bsf	ADCON0,GO	; start a/d conversion

ADCLOOP:
	btfsc	ADCON0,GO	;WAIT FOR CONVERSION TO FINISH
	goto	ADCLOOP

	bcf	PIR1,ADIF	; CLEAR CONVERSION COMPLETE FLAG

;COMPARISON WITH THE SETPOINT====================  

	movf	ADRESL,W

	sublw	.83		;FOR SETPOINT 40 DEGREES
	movwf	RES1
	btfsc	RES1,7		; CHECK WHETHER THE MSB IS 1 ,IF SO IT MEANS
; THAT TEMP>40 HENCE CALL 80% PWMDUTYCYCLE  
	goto	PWM80

	sublw	.73		; FOR 35 DEGREES
	movwf	RES2
	btfsc	RES2,7		;CHECK WHETHER THE MSB IS 1 ,IF SO IT MEANS
; THAT TEMP>35 HENCE CALL 20% PWMDUTYCYCLE  
	goto	PWM20

	goto	PWM1		; IF THE ABOVE TWO CONDS DOES NT SATISFY CALL
; 1% PWMDUTY CYCLE  


;PWMCYCLES======================================== ==  


PWM80:
	banksel	PR2
	movlw	0X31
	movwf	PR2		; FREQUENCY IS SET FOR 10MICROSECS

	bcf	STATUS,RP0
	bcf	STATUS,RP1
	movlw	0X48
	movwf	CCPR1L
	movlw	0X0C
	movwf	CCP1CON

;TRISC Setting for output  
	banksel	TRISC
	bcf	TRISC, PWM1;+++++++++out of range

	banksel	T2CON
;TMR2 Prescale selection(PRESCALE TO 1:16 AND POSTSCLE TO 1:1) and TMR2 Turn On  
	movlw	0X07
	movwf	T2CON

	goto	LOOP


PWM20:	
	banksel	PR2		;FOR 20%DUTYCYCLE
	movlw	0X31
	movwf	PR2		; FREQUENCY IS SET FOR 10MICROSECS

	bcf	STATUS,RP0
	bcf	STATUS,RP1
	movlw	0X0A
	movwf	CCPR1L
	movlw	0X0C
	movwf	CCP1CON

;TRISC Setting for output  
	banksel	TRISC
	bcf	TRISC, PWM1;++++++ out of range !!!

	banksel	T2CON
;TMR2 Prescale selection(PRESCALE TO 1:16 AND POSTSCLE TO 1:1) and TMR2 Turn On  
	movlw	0x07
	movwf	T2CON

	goto	LOOP

PWM1:	
	banksel	PR2		; FOR 1% DUTYCYCLE
	movlw	0X31
	movwf	PR2		; FREQUENCY IS SET FOR 10MICROSECS

	bcf	STATUS,RP0
	bcf	STATUS,RP1

	movlw	0X00
	movwf	CCPR1L
	movlw	0X2C
	movwf	CCP1CON

;TRISC Setting for output  
	banksel	TRISC
	bcf	TRISC, PWM1;++++++++++++ out of range

	banksel	T2CON
;TMR2 Prescale selection(PRESCALE TO 1:16 AND POSTSCLE TO 1:1) and TMR2 Turn On  
	movlw	0x07
	movwf	T2CON

	goto	LOOP

	end

EDIT:
Dont forget to add the CONFIG in the header.
 
Last edited:

kingsden

New Member
i changed that pwm1 to 2 and it is showing no errors.....i am nt getting proper o/p

the first stimulus value is 0x54 which is 84 in decimal.....when i subtract from 83 i shud get FF in res1 but i am getting 53 over der......
the program shud go to pwm80 and display a 0x48 in ccpr1l and 0x0c in ccp1con.....
but it is goin to pwm20 and displayin 0x0C in ccp1con and 0x0a in ccpr1l......

can u tell me what is d problem.......thank you for making it error free
 

ericgibbs

Well-Known Member
Most Helpful Member
i changed that pwm1 to 2 and it is showing no errors.....i am nt getting proper o/p

the first stimulus value is 0x54 which is 84 in decimal.....when i subtract from 83 i shud get FF in res1 but i am getting 53 over der......
the program shud go to pwm80 and display a 0x48 in ccpr1l and 0x0c in ccp1con.....
but it is goin to pwm20 and displayin 0x0C in ccp1con and 0x0a in ccpr1l......

can u tell me what is d problem.......thank you for making it error free
hi,
Which assembler are you using.?

Also what is your CONFIG word, crystal freq, etc.??
 

ericgibbs

Well-Known Member
Most Helpful Member
i changed that pwm1 to 2 and it is showing no errors.....i am nt getting proper o/p

the first stimulus value is 0x54 which is 84 in decimal.....when i subtract from 83 i shud get FF in res1 but i am getting 53 over der......
the program shud go to pwm80 and display a 0x48 in ccpr1l and 0x0c in ccp1con.....
but it is goin to pwm20 and displayin 0x0C in ccp1con and 0x0a in ccpr1l......

can u tell me what is d problem.......thank you for making it error free
hi,
Still no answer to my question.?

The reason you are not reading ADRESL correctly, is because you are not switching to Bank1 to read it.
Change the code to read:

Code:
	BSF STATUS,RP0
	MOVF ADRESL,W
	BCF STATUS,RP0
Also add a short delay after GO before you test /GO.
 
Last edited:

kingsden

New Member
sry for d late reply( i was out!).....
The assembler which i am using is MPASM......

I am giving
0x54
0x55
0x50
0x34
0x43
0x22
as the stimulus but it is only taking 0x54 and 0x55...and not proceeding for the next inputs........i am also getting a message

ADC-W0010: A Minimum of 2 TADs are required before another conversion should be started.
MAXIMUM number of warnings/errors exceeded 200, program execution halted.

ur giving gr8 support...thx.....i donno how to make dat look good thin while postin...so i am uploading the modified code.....
 

Attachments

Last edited:

ericgibbs

Well-Known Member
Most Helpful Member
sry for d late reply( i was out!).....
The assembler which i am using is MPASM......

I am giving
0x54
0x55
0x50
0x34
0x43
0x22
as the stimulus but it is only taking 0x54 and 0x55...and not proceeding for the next inputs........i am also getting a message

ADC-W0010: A Minimum of 2 TADs are required before another conversion should be started.
MAXIMUM number of warnings/errors exceeded 200, program execution halted.

ur giving gr8 support...thx
Did you add the Bank1 changes I posted.
Also the delay I suggested takes care of the TADs...:)

Code:
	bsf	ADCON0,GO	; start a/d conversion
[B] put a short delay here[/B]
ADCLOOP:
	btfsc	ADCON0,GO	;WAIT FOR CONVERSION TO FINISH
	goto	ADCLOOP

EDIT:
looked at the new listing, I see the Banking.
 
Last edited:

kingsden

New Member
when i am adding a delay i am not getting any Tad messages but i am not getting the correct pwm for 50 as an input ........

when i am removing a delay i am getting that pwm o/p crctly but it is only taking 0x54 and 0x55 as input......and also dat Tad error msg is comin..........

here is d delay i have added

LOOP:
banksel ADCON0
bsf ADCON0,GO ; start a/d conversion

MOVLW 0XFA ;delay
MOVWF RG1
NOP
DECFSZ RG1,1
GOTO $-1
ADCLOOP:
btfsc ADCON0,GO ;WAIT FOR CONVERSION TO FINISH

i initialised rg1 at 0x32
 
Last edited:

ericgibbs

Well-Known Member
Most Helpful Member
If you look at the datasheet for the PIC, adc section it tells you how to calculate the required delay... it is necessary.

Still dont know your CONFIG, crystal freq etc, despite asking 3 times.!

How do you expect us to help if you dont answer simple questions.:(
 

kingsden

New Member
i am using the 20 mhz oscillator frequency for the pic and for the adc i am using FRC (clock derived from the internal A/D RC oscillator).....

as such i did not write anythin into the configuration word( i knew abt it jus nw!!).....
sry for nt answering properly....
i have read dat acquisition time before,,but nt able to understand it.....so i jus tried out a random delay......
 

kingsden

New Member
i am using the 20 mhz oscillator frequency for the pic and for the adc i am using FRC (clock derived from the internal A/D RC oscillator).....

as such i did not write anythin into the configuration word( i knew abt it jus nw!!).....
sry for nt answering properly....
i have read dat acquisition time before,,but nt able to understand it.....so i jus tried out a random delay......
 

ericgibbs

Well-Known Member
Most Helpful Member
i am using the 20 mhz oscillator frequency for the pic and for the adc i am using FRC (clock derived from the internal A/D RC oscillator).....

as such i did not write anythin into the configuration word( i knew abt it jus nw!!).....
sry for nt answering properly....
i have read dat acquisition time before,,but nt able to understand it.....so i jus tried out a random delay......
hi,
If you look in the 'microchip' folder on your hard drive, find the 'templates' sub folder for the PIC you are using, it will give details of the CONFIG settings.
Also look at the INCLUDE files for the PIC in a sub folder, useful for study.

If you dont set the CONFIG, you could get unexpected problems when running the program in a PIC.

A longer time delay than the miniumum time delay for the ADC isnt a problem.

Obviously it not very elegant as it 'wastes' time, but in your application [tempr control] you will not be aware of this extra time delay.:)
 

kingsden

New Member
__CONFIG _CONFIG1, _CP_OFF & _CCP1_RB0 & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _MCLR_ON & _PWRTE_ON & _WDT_OFF & _INTRC_IO
__CONFIG _CONFIG2, _IESO_OFF & _FCMEN_OFF

This is wat i found over der!!.....

the extra time delay isn't a problem but i am not getting the proper pwm when i am using the delay ......
when i am nt usin it i am getting the proper pwm( it is only showing the pwm corresponding to two stimuli..) but with a warning that a wrapover is happening and a Tad problem......
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top