kısalan palsler nasıl düzeltilir(yardım)

nanit

Üye
Katılım
21 Ocak 2011
Mesajlar
159
Puanları
1
Yaş
33
bir p12f683 projesiyle yine karşınızdayım arkadaşlar :D pwm çıkışı aldıgım gp2 bacagındaki palsler çok düzensiz ve palsler git gide küçülüyor bunun nedeni nedir ccs c ile yazıyorum programı yardımlarınız için şimdiden teşekkürler
 
haha :D valla bu mikrodenetliyiciyle yaptıgım tüm programlar öyle bunun genel bir sorunudur diye zannettim program kodları
HTML:
#include <12f683.h>
#device adc=10
#use delay(clock=40000000)
#fuses NOWDT, INTRC_IO, NOMCLR, PUT
#use fast_io(a)
int16 i=125;
void main(void)
{
          set_tris_a(9);
         setup_adc(ADC_CLOCK_DIV_16);
    setup_adc_ports(ALL_ANALOG);
    set_adc_channel(0);
    delay_us(10);
     setup_ccp1(ccp_pwm);
setup_timer_2(t2_div_by_1,255,1);
     set_pwm1_duty(i);
    while(1)
  {        
 i=read_adc();
    set_pwm1_duty(i);
   delay_us(250);
        }}
 
Haha:D, Overclock mu yaptınız? Semptomları neler?
Bu MCU ile çalışırken bu defineları kullanıyorsanız; MCU nun değil ama sizin genel sorununuz overclock aşkınız olabilir!!!
 
C den pek anlamam ama aklıma gelen 2 ihtimal;
-PWM çıkışı analog pin olarak ayarlanmış heral.. Alakası olabilir mi?
-Delay clock 40MHz.. O fark yaratabilir mi?
 
Şöyle dene:

Kod:
#device adc=10
#FUSES NOWDT                    //No Watch Dog Timer
#FUSES INTRC_IO                 //Internal RC Osc, no CLKOUT
#FUSES NOBROWNOUT               //No brownout reset
#FUSES INTRC_IO
#FUSES NOMCLR
#use delay(int=4000000)


Kod:
int16 i=125;
void main()
{
   setup_adc_ports(sAN0);
   setup_adc(ADC_CLOCK_DIV_16);
   setup_timer_2(T2_DIV_BY_1,255,1);    
   setup_ccp1(CCP_PWM);
   set_pwm1_duty(i);
   setup_comparator(NC_NC);
   setup_oscillator(OSC_4MHZ);
 while(TRUE)
  {
[B]   setup_adc(ADC_CLOCK_DIV_16);
    delay_ms(20);[/B]
     i=read_adc();
      set_pwm1_duty(i);
   }
}

---------------

@GüvTek , ccs c aşağıdakini senin için üretiyor : :rolleyes:

Kod:
CCS PCM C Compiler, Version 4.138, 56899               27-Kas-12 02:23
               Filename:   C:\Users\AB\Desktop\Yeni klasör (2)\main.lst
               ROM used:   145 words (7%)
                           Largest free fragment is 1903
               RAM used:   6 (5%) at main() level
                           7 (5%) worst case
               Stack:     1 locations
*
0000:  MOVLW  00
0001:  MOVWF  0A
0002:  GOTO   018
0003:  NOP
.................... #include <main.h> 
.................... #include <12F683.h> 
.................... //////// Standard Header file for the PIC12F683 device //////////////// 
.................... #device PIC12F683 
.................... #list 
....................  
.................... #device adc=10 
....................  
.................... #FUSES NOWDT                    //No Watch Dog Timer 
.................... #FUSES INTRC_IO                 //Internal RC Osc, no CLKOUT 
.................... #FUSES NOBROWNOUT               //No brownout reset 
.................... #FUSES INTRC_IO 
.................... #FUSES NOMCLR 
....................  
.................... #use delay(int=4000000) 
0004:  MOVLW  26
0005:  MOVWF  04
0006:  MOVF   00,W
0007:  BTFSC  03.2
0008:  GOTO   017
0009:  MOVLW  01
000A:  MOVWF  21
000B:  CLRF   20
000C:  DECFSZ 20,F
000D:  GOTO   00C
000E:  DECFSZ 21,F
000F:  GOTO   00B
0010:  MOVLW  4A
0011:  MOVWF  20
0012:  DECFSZ 20,F
0013:  GOTO   012
0014:  GOTO   015
0015:  DECFSZ 00,F
0016:  GOTO   009
0017:  GOTO   072 (RETURN)
....................  
....................  
....................  
....................  
.................... int16 i=125; 
....................  
.................... void main() 
.................... { 
0018:  CLRF   04
0019:  MOVLW  1F
001A:  ANDWF  03,F
001B:  MOVLW  61
001C:  BSF    03.5
001D:  MOVWF  0F
001E:  MOVF   0F,W
001F:  BCF    03.5
0020:  CLRF   25
0021:  MOVLW  7D
0022:  MOVWF  24
0023:  BCF    1F.6
0024:  BSF    03.5
0025:  BCF    1F.0
0026:  BCF    1F.1
0027:  BCF    1F.2
0028:  BCF    1F.3
0029:  MOVLW  07
002A:  BCF    03.5
002B:  MOVWF  19
....................    setup_adc_ports(sAN0); 
002C:  BCF    1F.6
002D:  BSF    03.5
002E:  BSF    1F.0
002F:  BCF    1F.1
0030:  BCF    1F.2
0031:  BCF    1F.3
....................    setup_adc(ADC_CLOCK_DIV_16); 
0032:  BSF    1F.4
0033:  BCF    1F.5
0034:  BSF    1F.6
0035:  BCF    03.5
0036:  BSF    1F.7
0037:  BSF    1F.0
....................    setup_timer_2(T2_DIV_BY_1,255,1);     
0038:  MOVLW  00
0039:  MOVWF  21
003A:  IORLW  04
003B:  MOVWF  12
003C:  MOVLW  FF
003D:  BSF    03.5
003E:  MOVWF  12
....................  
....................    setup_ccp1(CCP_PWM); 
003F:  BCF    05.2
0040:  BCF    03.5
0041:  BCF    05.2
0042:  MOVLW  0C
0043:  MOVWF  15
....................    set_pwm1_duty(i); 
0044:  MOVF   25,W
0045:  MOVWF  22
0046:  MOVF   24,W
0047:  MOVWF  21
0048:  RRF    22,F
0049:  RRF    21,F
004A:  RRF    22,F
004B:  RRF    21,F
004C:  RRF    22,F
004D:  MOVF   21,W
004E:  MOVWF  13
004F:  RRF    22,F
0050:  RRF    22,W
0051:  ANDLW  30
0052:  MOVWF  20
0053:  MOVF   15,W
0054:  ANDLW  CF
0055:  IORWF  20,W
0056:  MOVWF  15
....................    setup_comparator(NC_NC); 
0057:  MOVLW  07
0058:  MOVWF  19
0059:  BSF    03.5
005A:  MOVF   05,W
005B:  MOVWF  05
005C:  MOVLW  02
005D:  BCF    03.5
005E:  MOVWF  20
005F:  DECFSZ 20,F
0060:  GOTO   05F
0061:  GOTO   062
0062:  NOP
0063:  MOVF   19,W
0064:  BCF    0C.3
....................    setup_oscillator(OSC_4MHZ); 
0065:  MOVLW  61
0066:  BSF    03.5
0067:  MOVWF  0F
0068:  MOVF   0F,W
....................  
....................  while(TRUE) 
....................   { 
....................    setup_adc(ADC_CLOCK_DIV_16); 
0069:  BSF    1F.4
006A:  BCF    1F.5
006B:  BSF    1F.6
006C:  BCF    03.5
006D:  BSF    1F.7
006E:  BSF    1F.0
....................     delay_ms(20); 
006F:  MOVLW  14
0070:  MOVWF  26
0071:  GOTO   004
....................      i=read_adc(); 
0072:  BSF    1F.1
0073:  BTFSC  1F.1
0074:  GOTO   073
0075:  BSF    03.5
0076:  MOVF   1E,W
0077:  BCF    03.5
0078:  MOVWF  24
0079:  MOVF   1E,W
007A:  MOVWF  25
....................       set_pwm1_duty(i); 
007B:  MOVF   25,W
007C:  MOVWF  22
007D:  MOVF   24,W
007E:  MOVWF  21
007F:  RRF    22,F
0080:  RRF    21,F
0081:  RRF    22,F
0082:  RRF    21,F
0083:  RRF    22,F
0084:  MOVF   21,W
0085:  MOVWF  13
0086:  RRF    22,F
0087:  RRF    22,W
0088:  ANDLW  30
0089:  MOVWF  20
008A:  MOVF   15,W
008B:  ANDLW  CF
008C:  IORWF  20,W
008D:  MOVWF  15
....................    } 
008E:  BSF    03.5
008F:  GOTO   069
.................... } 
0090:  SLEEP
Configuration Fuses:
   Word  1: 3CC4   INTRC_IO NOWDT PUT NOMCLR NOPROTECT NOCPD NOBROWNOUT IESO FCMEN
 
Şöyle dene:

Kod:
#device adc=10
#FUSES NOWDT                    //No Watch Dog Timer
#FUSES INTRC_IO                 //Internal RC Osc, no CLKOUT
#FUSES NOBROWNOUT               //No brownout reset
#FUSES INTRC_IO
#FUSES NOMCLR
#use delay(int=4000000)


Kod:
int16 i=125;
void main()
{
   setup_adc_ports(sAN0);
   setup_adc(ADC_CLOCK_DIV_16);
   setup_timer_2(T2_DIV_BY_1,255,1);    
   setup_ccp1(CCP_PWM);
   set_pwm1_duty(i);
   setup_comparator(NC_NC);
   setup_oscillator(OSC_4MHZ);
 while(TRUE)
  {
[B]   setup_adc(ADC_CLOCK_DIV_16);
    delay_ms(20);[/B]
     i=read_adc();
      set_pwm1_duty(i);
   }
}

---------------

@GüvTek , ccs c aşağıdakini senin için üretiyor : :rolleyes:

Kod:
CCS PCM C Compiler, Version 4.138, 56899               27-Kas-12 02:23
               Filename:   C:\Users\AB\Desktop\Yeni klasör (2)\main.lst
               ROM used:   145 words (7%)
                           Largest free fragment is 1903
               RAM used:   6 (5%) at main() level
                           7 (5%) worst case
               Stack:     1 locations
*
0000:  MOVLW  00
0001:  MOVWF  0A
0002:  GOTO   018
0003:  NOP
.................... #include <main.h> 
.................... #include <12F683.h> 
.................... //////// Standard Header file for the PIC12F683 device //////////////// 
.................... #device PIC12F683 
.................... #list 
....................  
.................... #device adc=10 
....................  
.................... #FUSES NOWDT                    //No Watch Dog Timer 
.................... #FUSES INTRC_IO                 //Internal RC Osc, no CLKOUT 
.................... #FUSES NOBROWNOUT               //No brownout reset 
.................... #FUSES INTRC_IO 
.................... #FUSES NOMCLR 
....................  
.................... #use delay(int=4000000) 
0004:  MOVLW  26
0005:  MOVWF  04
0006:  MOVF   00,W
0007:  BTFSC  03.2
0008:  GOTO   017
0009:  MOVLW  01
000A:  MOVWF  21
000B:  CLRF   20
000C:  DECFSZ 20,F
000D:  GOTO   00C
000E:  DECFSZ 21,F
000F:  GOTO   00B
0010:  MOVLW  4A
0011:  MOVWF  20
0012:  DECFSZ 20,F
0013:  GOTO   012
0014:  GOTO   015
0015:  DECFSZ 00,F
0016:  GOTO   009
0017:  GOTO   072 (RETURN)
....................  
....................  
....................  
....................  
.................... int16 i=125; 
....................  
.................... void main() 
.................... { 
0018:  CLRF   04
0019:  MOVLW  1F
001A:  ANDWF  03,F
001B:  MOVLW  61
001C:  BSF    03.5
001D:  MOVWF  0F
001E:  MOVF   0F,W
001F:  BCF    03.5
0020:  CLRF   25
0021:  MOVLW  7D
0022:  MOVWF  24
0023:  BCF    1F.6
0024:  BSF    03.5
0025:  BCF    1F.0
0026:  BCF    1F.1
0027:  BCF    1F.2
0028:  BCF    1F.3
0029:  MOVLW  07
002A:  BCF    03.5
002B:  MOVWF  19
....................    setup_adc_ports(sAN0); 
002C:  BCF    1F.6
002D:  BSF    03.5
002E:  BSF    1F.0
002F:  BCF    1F.1
0030:  BCF    1F.2
0031:  BCF    1F.3
....................    setup_adc(ADC_CLOCK_DIV_16); 
0032:  BSF    1F.4
0033:  BCF    1F.5
0034:  BSF    1F.6
0035:  BCF    03.5
0036:  BSF    1F.7
0037:  BSF    1F.0
....................    setup_timer_2(T2_DIV_BY_1,255,1);     
0038:  MOVLW  00
0039:  MOVWF  21
003A:  IORLW  04
003B:  MOVWF  12
003C:  MOVLW  FF
003D:  BSF    03.5
003E:  MOVWF  12
....................  
....................    setup_ccp1(CCP_PWM); 
003F:  BCF    05.2
0040:  BCF    03.5
0041:  BCF    05.2
0042:  MOVLW  0C
0043:  MOVWF  15
....................    set_pwm1_duty(i); 
0044:  MOVF   25,W
0045:  MOVWF  22
0046:  MOVF   24,W
0047:  MOVWF  21
0048:  RRF    22,F
0049:  RRF    21,F
004A:  RRF    22,F
004B:  RRF    21,F
004C:  RRF    22,F
004D:  MOVF   21,W
004E:  MOVWF  13
004F:  RRF    22,F
0050:  RRF    22,W
0051:  ANDLW  30
0052:  MOVWF  20
0053:  MOVF   15,W
0054:  ANDLW  CF
0055:  IORWF  20,W
0056:  MOVWF  15
....................    setup_comparator(NC_NC); 
0057:  MOVLW  07
0058:  MOVWF  19
0059:  BSF    03.5
005A:  MOVF   05,W
005B:  MOVWF  05
005C:  MOVLW  02
005D:  BCF    03.5
005E:  MOVWF  20
005F:  DECFSZ 20,F
0060:  GOTO   05F
0061:  GOTO   062
0062:  NOP
0063:  MOVF   19,W
0064:  BCF    0C.3
....................    setup_oscillator(OSC_4MHZ); 
0065:  MOVLW  61
0066:  BSF    03.5
0067:  MOVWF  0F
0068:  MOVF   0F,W
....................  
....................  while(TRUE) 
....................   { 
....................    setup_adc(ADC_CLOCK_DIV_16); 
0069:  BSF    1F.4
006A:  BCF    1F.5
006B:  BSF    1F.6
006C:  BCF    03.5
006D:  BSF    1F.7
006E:  BSF    1F.0
....................     delay_ms(20); 
006F:  MOVLW  14
0070:  MOVWF  26
0071:  GOTO   004
....................      i=read_adc(); 
0072:  BSF    1F.1
0073:  BTFSC  1F.1
0074:  GOTO   073
0075:  BSF    03.5
0076:  MOVF   1E,W
0077:  BCF    03.5
0078:  MOVWF  24
0079:  MOVF   1E,W
007A:  MOVWF  25
....................       set_pwm1_duty(i); 
007B:  MOVF   25,W
007C:  MOVWF  22
007D:  MOVF   24,W
007E:  MOVWF  21
007F:  RRF    22,F
0080:  RRF    21,F
0081:  RRF    22,F
0082:  RRF    21,F
0083:  RRF    22,F
0084:  MOVF   21,W
0085:  MOVWF  13
0086:  RRF    22,F
0087:  RRF    22,W
0088:  ANDLW  30
0089:  MOVWF  20
008A:  MOVF   15,W
008B:  ANDLW  CF
008C:  IORWF  20,W
008D:  MOVWF  15
....................    } 
008E:  BSF    03.5
008F:  GOTO   069
.................... } 
0090:  SLEEP
Configuration Fuses:
   Word  1: 3CC4   INTRC_IO NOWDT PUT NOMCLR NOPROTECT NOCPD NOBROWNOUT IESO FCMEN
verdiğiniz kodları denedim yine aynı düzensizlikte onun nedeni while döngüsü her tekrarındaki gecikme olabilirmi ?her tekrardaki zaman kaybını nasıl düzelte bilirim
 
.................... setup_adc_ports(sAN0); 002C: BCF 1F.6 002D: BSF 03.5 002E: BSF 1F.0 002F: BCF 1F.1 0030: BCF 1F.2 0031: BCF 1F.3



Esas komutta burada.. setup_adc_ports(ALL_ANALOG) yazıyor.. PWM çıkışı bulunun CCP pini de aynı zamanda analog pin.. Bunu kastetmiştim..

Bi de C bu kadar rezalet bi dilse uğraşmaya değmez.. İşlemci hızının a..sını bellemiş.. Aynı baytın bitlerini tek tek düzenleme mi yapılırmış..
 
...aynı düzensizlikte onun nedeni ...

Bu tip sorularında çalışma dosyasını olduğu gibi koy.
Yani ne ile deniyorsan o dahil ccsc çalışma dosyası dahil rar ile sıkıştır tek dosya yap bir yere yükle ...


---

O listeyi görmek isteyen kolayca görsün anlasın diye üretiyor...

Acemiler için kolaylıkları var.
Tanımlamaz isen yazdıklarına bakarak giriş -çıkış tanımlar ama bu fazla yer kaplar.
Bu yüzden all_analog olsada gereken pinden gerekeni çıkarır.
Senin gibi çok ileri düzey bit sayar kullanıcılar ise arkadaşın yaptığı gibi #use fast_io(a) gibi daha ekomik kullanılırlar .
 
Son düzenleme:

Forum istatistikleri

Konular
129,901
Mesajlar
931,145
Kullanıcılar
452,786
Son üye
mtnozkan35

Yeni konular

Geri
Üst