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 CCS Technical Support

Delay problem.

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



Joined: 31 Jan 2009
Posts: 59

View user's profile Send private message

Delay problem.
PostPosted: Fri Aug 14, 2009 9:55 am     Reply with quote

If i use delay_ms(time) with any time the program stops before the delay.
if i don't use delay, my program works just fine.
I've installed 3 version of windows, because I didn't have this kind of problem before, I've tried CCS 4.057, CCS PCWHD v4.084, and the same problem...
Did anyone had this problem before ?
Code:

void main()
{
int16 t;
t=100;
   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_comparator(NC_NC);
   setup_vref(FALSE);


  while ( TRUE )
   {
   if(input(PIN_A0))
      {
      output_low(PIN_A4);//stop faza scurta/lunga
      output_high(PIN_A5);//bec on
      output_low(PIN_A2);//proiectoare on
      delay_ms(t);
      output_low(PIN_A5);//bec off
      output_high(PIN_A2);//proiectoare off
      }
      else output_high(PIN_A4);
   }
}


the lst
Code:

*
0000:  MOVLW  00
0001:  MOVWF  0A
0002:  GOTO   004
0003:  NOP
0004:  CALL   3FF
0005:  BSF    03.5
0006:  MOVWF  10
0007:  MOVLW  00
0008:  MOVWF  0A
0009:  GOTO   01E
.................... #include "C:\Documents and Settings\Noyz2k\My Documents\flashuri noyz\flash12f675.h"
.................... #include <12F675.h>
.................... //////// Standard Header file for the PIC12F675 device ////////////////
.................... #device PIC12F675
.................... #list
.................... 
.................... 
.................... #FUSES NOWDT                    //No Watch Dog Timer
.................... #FUSES INTRC_IO                      //Low power osc < 200 khz
.................... #FUSES NOCPD                    //No EE protection
.................... #FUSES NOPROTECT                //Code not protected from reading
.................... #FUSES NOMCLR                   //Master Clear pin used for I/O
.................... #FUSES NOPUT                    //No Power Up Timer
.................... #FUSES BROWNOUT                 //Reset when brownout detected
.................... #FUSES BANDGAP_HIGH           
.................... #use delay(clock=4 000 000)
000A:  MOVLW  29
000B:  MOVWF  04
000C:  MOVF   00,W
000D:  BTFSC  03.2
000E:  GOTO   01D
000F:  MOVLW  01
0010:  MOVWF  21
0011:  CLRF   20
0012:  DECFSZ 20,F
0013:  GOTO   012
0014:  DECFSZ 21,F
0015:  GOTO   011
0016:  MOVLW  4A
0017:  MOVWF  20
0018:  DECFSZ 20,F
0019:  GOTO   018
001A:  GOTO   01B
001B:  DECFSZ 00,F
001C:  GOTO   00F
001D:  RETLW  00
.................... 
.................... 
.................... 
.................... 
.................... void main()
.................... {
001E:  CLRF   04
001F:  MOVLW  1F
0020:  ANDWF  03,F
0021:  BCF    1F.6
0022:  BSF    03.5
0023:  BCF    1F.0
0024:  BCF    1F.1
0025:  BCF    1F.2
0026:  BCF    1F.3
0027:  MOVLW  07
0028:  BCF    03.5
0029:  MOVWF  19
.................... int16 t;
.................... t=100;
002A:  CLRF   27
002B:  MOVLW  64
002C:  MOVWF  26
....................    setup_adc_ports(NO_ANALOGS|VSS_VDD);
002D:  BCF    1F.6
002E:  BSF    03.5
002F:  BCF    1F.0
0030:  BCF    1F.1
0031:  BCF    1F.2
0032:  BCF    1F.3
....................    setup_adc(ADC_OFF);
0033:  BCF    03.5
0034:  BCF    1F.0
....................    setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
0035:  BSF    03.5
0036:  MOVF   01,W
0037:  ANDLW  C7
0038:  IORLW  08
0039:  MOVWF  01
....................    setup_timer_1(T1_DISABLED);
003A:  BCF    03.5
003B:  CLRF   10
....................    setup_comparator(NC_NC);
003C:  MOVLW  07
003D:  MOVWF  19
003E:  BSF    03.5
003F:  MOVF   05,W
0040:  MOVWF  05
0041:  MOVLW  03
0042:  BCF    03.5
0043:  MOVWF  20
0044:  DECFSZ 20,F
0045:  GOTO   044
0046:  MOVF   19,W
0047:  BCF    0C.3
....................    setup_vref(FALSE);
0048:  BSF    03.5
0049:  CLRF   19
.................... 
.................... 
....................   while ( TRUE ) 
....................    {
....................    if(input(PIN_A0))
004A:  BSF    05.0
004B:  BCF    03.5
004C:  BTFSS  05.0
004D:  GOTO   070
....................       {
....................       output_low(PIN_A4);//stop faza scurta/lunga
004E:  BSF    03.5
004F:  BCF    05.4
0050:  BCF    03.5
0051:  BCF    05.4
....................       output_high(PIN_A5);//bec on
0052:  BSF    03.5
0053:  BCF    05.5
0054:  BCF    03.5
0055:  BSF    05.5
....................       output_low(PIN_A2);//proiectoare on
0056:  BSF    03.5
0057:  BCF    05.2
0058:  BCF    03.5
0059:  BCF    05.2
....................       delay_ms(t);
005A:  MOVF   27,W
005B:  MOVWF  28
005C:  INCF   28,F
005D:  DECF   28,F
005E:  BTFSC  03.2
005F:  GOTO   064
0060:  MOVLW  FF
0061:  MOVWF  29
0062:  CALL   00A
0063:  GOTO   05D
0064:  MOVF   26,W
0065:  MOVWF  29
0066:  CALL   00A
....................       output_low(PIN_A5);//bec off
0067:  BSF    03.5
0068:  BCF    05.5
0069:  BCF    03.5
006A:  BCF    05.5
....................       output_high(PIN_A2);//proiectoare off
006B:  BSF    03.5
006C:  BCF    05.2
006D:  BCF    03.5
006E:  BSF    05.2
....................       }
....................       else output_high(PIN_A4);
006F:  GOTO   074
0070:  BSF    03.5
0071:  BCF    05.4
0072:  BCF    03.5
0073:  BSF    05.4
....................    }
0074:  BSF    03.5
0075:  GOTO   04A
.................... }
0076:  SLEEP

Configuration Fuses:
   Word  1: 31D4   NOWDT NOCPD NOPROTECT NOMCLR NOPUT INTRC_IO BROWNOUT BANDGAP_HIGH
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Aug 14, 2009 11:12 am     Reply with quote

What do you mean by "it stops" ?

Does it stop running as a stand-alone program ?
Or does it appear to stop when running it under the debugger ?
Tell us the testing environment.
noyz



Joined: 31 Jan 2009
Posts: 59

View user's profile Send private message

PostPosted: Fri Aug 14, 2009 7:45 pm     Reply with quote

Proteus 7.1 and the circuit verified with oscilloscope.
In Proteus I've put the PIC, logic input and logic probes.
It stops after doing everything before delay.
Ttelmah
Guest







PostPosted: Sat Aug 15, 2009 9:17 am     Reply with quote

Obvious question. Have you tried removing the delay?.
Add a simple 'delay' count loop of your own making. Does it still stop?.

Things that might apply:
One of the circuits you are switching with your 'output' statements, is spiking the PIC.
How is the watchdog setup?.

There is nothing special about delay. It is just a carefully timed loop. If the code goes wrong _before_ the delay, look what is being done _before_ the delay....

Best Wishes
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