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

function not call another function

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



Joined: 15 Jun 2005
Posts: 2

View user's profile Send private message

function not call another function
PostPosted: Fri Jul 15, 2005 10:58 am     Reply with quote

hellow all,
i make this example to monitoring the called and return of function

main() call setled and this call set_ledon but not call set_ledoff ????
the ccs c not call function with function ?????
no anderstand, please help-me

thanks

0000: MOVLW 00
0001: MOVWF PCLATH
0002: GOTO main
0003: NOP
.................... #include <16F628.h>
.................... //////// Standard Header file for the PIC16F628 device ////////////////
.................... #device PIC16F628
.................... #list
....................
.................... #device *=16
.................... #use delay(clock=4000000)
0004: MOVLW ??65535
0005: MOVWF FSR
0006: BCF STATUS.7
0007: MOVF INDF,W
0008: BTFSC STATUS.2
0009: GOTO 019
000A: MOVLW 01
000B: MOVWF @78
000C: CLRF @77
000D: DECFSZ @77,F
000E: GOTO 00D
000F: DECFSZ @78,F
0010: GOTO 00C
0011: MOVLW 4A
0012: MOVWF @77
0013: DECFSZ @77,F
0014: GOTO 013
0015: NOP
0016: NOP
0017: DECFSZ INDF,F
0018: GOTO 00A
0019: GOTO 023 (RETURN)
.................... #fuses NOWDT, INTRC_IO, PUT, NOPROTECT, NOBROWNOUT, MCLR, NOLVP, NOCPD
....................
.................... void set_ledon(){
.................... output_high( PIN_B0 );
001A: BSF STATUS.5
001B: BCF TRISB.0
001C: BCF STATUS.5
001D: BSF PORTB.0
.................... }
....................
.................... void set_ledoff(){
.................... output_low( PIN_B0 );
*
0025: BSF STATUS.5
0026: BCF TRISB.0
0027: BCF STATUS.5
0028: BCF PORTB.0
.................... }
....................
.................... void setled(){
.................... set_ledon();
.................... delay_ms(500);
*
001E: MOVLW 02
001F: MOVWF @@22
0020: MOVLW FA
0021: MOVWF ??65535
0022: GOTO @delay_ms1
0023: DECFSZ @@22,F
0024: GOTO 020
.................... set_ledoff();
.................... }
*
0029: GOTO 032 (RETURN)
....................
.................... void main(){
.................... int x;
002A: CLRF FSR
002B: BCF STATUS.7
002C: MOVLW 1F
002D: ANDWF STATUS,F
002E: MOVLW 07
002F: MOVWF ADCON0
.................... x = 0;
0030: CLRF x
.................... do{
.................... setled();
0031: GOTO setled
.................... x += 1;
0032: MOVLW 01
0033: ADDWF x,F
.................... }while( x <= 10 );
0034: MOVF x,W
0035: SUBLW 0A
0036: BTFSC STATUS.0
0037: GOTO 031
....................
.................... }
....................
0038: SLEEP
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Fri Jul 15, 2005 11:07 am     Reply with quote

A classic error.

Code:
void setled(){
  set_ledon();
  delay_ms(500);
  set_ledoff();
}


The function set_ledoff is called, but within a few microseconds you are calling set_ledon again. The led is going off but only so short that you don't see it.
Change to:
Code:
void setled(){
  set_ledon();
  delay_ms(500);
  set_ledoff();
  delay_ms(500);
}
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Fri Jul 15, 2005 2:14 pm     Reply with quote

If a function is only called once then it is inline unless you specify it with #separate. Notice that
Code:
.................... void set_ledoff(){
.................... output_low( PIN_B0 );
*
0025: BSF STATUS.5


comes right after

Code:
.................... set_ledon();
.................... delay_ms(500);
*
001E: MOVLW 02
001F: MOVWF @@22
0020: MOVLW FA
0021: MOVWF ??65535
0022: GOTO @delay_ms1
0023: DECFSZ @@22,F
0024: GOTO 020
.................... set_ledoff();
.................... }


24 then 25

The reason that it might seem like the function is not being called is what ckielstra pointed out.
austin



Joined: 15 Jun 2005
Posts: 2

View user's profile Send private message

PostPosted: Fri Jul 22, 2005 12:29 pm     Reply with quote

ok, thanks
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