pic24fj256gb110 Osilatör Sorunu ( input 20 MHZ)

Başlatan ehliseyf, 12 Ekim 2016, 16:26:20

ehliseyf

Girişte 20 mhz ile harici osilatör kullanıyorum. USB haberleşmesi için PLL5 ile 48MHZ ayarı yaptım. Aynı kodlar önceden çalışıyordu. MPLAB X e ve CCS C ye güncelleme gelmiş. Şuan Osilatör kayma yapıyor. 1 sn led yakıp söndürüyorum. 1.7 1.8 civarında yanıp sönüyor. Kodların bir bölümü ektedir.
#include <24FJ256GB110.h>
#use delay(clock=48000000)

#FUSES HS
//#FUSES ECPLL
//#FUSES NOMCLR                  
#FUSES NOWDT                    //No Watch Dog Timer 
#FUSES NOJTAG                   //JTAG disabled 
#FUSES NOPROTECT                //Code not protected from reading 
#FUSES NOWRT                    //Program memory not write protected 
#FUSES NODEBUG                  //No Debug mode for ICD 
#FUSES ICSP1                    //ICD uses PGC1/PGD1 pins 
#FUSES NOCKSFSM                 //Clock Switching is disabled, fail Safe clock monitor is disabled 
#FUSES NOOSCIO                  //OSC2 is clock output           
#FUSES PR_PLL                   //Enable PLL for primary oscillator? 
#FUSES PLL5                     //Divide By 5(20MHz oscillator input) 
#FUSES DISUVREG        


#use fast_io(a) // Port yönlendirme komutlar? a portu için geçerli
#use fast_io(b) // Port yönlendirme komutlar? b portu için geçerli
#use fast_io(c) // Port yönlendirme komutlar? c portu için geçerli
#use fast_io(d) // Port yönlendirme komutlar? d portu için geçerli
#use fast_io(e) // Port yönlendirme komutlar? e portu için geçerli
#use fast_io(f) // Port yönlendirme komutlar? f portu için geçerli
#use fast_io(g) // Port yönlendirme komutlar? g portu için geçerli

#use spi(MASTER, baud=115200, MODE=0, DI=pin_E9, DO=pin_E5, CLK=pin_A0, bits=8, MSB_FIRST)

#define USB_HID_DEVICE     TRUE           
#define USB_EP1_TX_ENABLE  USB_ENABLE_INTERRUPT //Uçnokta1'de Kesme transferi aktif
#define USB_EP1_RX_ENABLE  USB_ENABLE_INTERRUPT      
#define USB_EP1_TX_SIZE    64                //Uçnokta1 için maksimum al?nacak ve gonderilecek
#define USB_EP1_RX_SIZE    64                //veri boyutu (64 byte)


#include <pic24_usb.h> 
#include <USB_Konfigurasyon.h>                //USB konfigurasyon bilgileri bu dosyadad?r.
#include <usb.c>    
#include <stdlib.h>
#include <math.h>

unsigned int8 paket[65];
unsigned int8 gond_paket[65];

#word U1OTGCON = 0x0486    // USB on the go reg 
#bit OTGEN = U1OTGCON.2    // enable bit for OTG 
#bit DPPULUP = U1OTGCON.7  // pull ups on USB

#define UcNokta1       1 
#define usb_nm2        paket[2]
#define Serial_komut   paket[1]
#define komut          paket[0]
#define LED    PIN_E4
//#define SPICLK PIN_A0
#define DRDY   PIN_B2
//#define DIN    PIN_E9
#define GPI04  PIN_B3
#define GPI03  PIN_B4
#define GPI02  PIN_B5
#define GPI01  PIN_E8
#define CS     PIN_G8
#define STRT   PIN_G7
#define RST    PIN_C4
#define PWDN   PIN_E6
#define buton  PIN_E7
//#define DOUT   PIN_E5
//#define LED    PIN_E4

arada fonksiyonlarım.

void main()
{
    
 //  setup_psp(PSP_DISABLED);        // PSP birimi devre d???
   setup_spi(SPI_SS_DISABLED);     // SPI birimi devre d???
  // setup_timer_1(T1_DISABLED);     // T1 zamanlay?c?s? devre d???
  // setup_timer_2(T2_DISABLED,0,1); // T2 zamanlay?c?s? devre d???
   setup_adc(ADC_OFF);         // ADC kipi devre d??? b?rak?l?yor.
   setup_adc_ports(NO_ANALOGS);   // ADC portlar? ADC amaçl? kullan?lm?yor.
   //setup_CCP1(CCP_OFF);            // CCP1 birimi devre d???
   //setup_CCP2(CCP_OFF);            // CCP2 birimi devre d???
   set_tris_a(0x0000);   
   set_tris_b(0x0004);   
   set_tris_c(0x0000);
   set_tris_d(0x0000);  
   set_tris_e(0x0280);    
   set_tris_f(0x0000);
   set_tris_g(0x0000);  
   
   output_a(0x0000);
   output_b(0x0000);
   output_c(0x0000);
   output_d(0x0000);
   output_e(0x0000);
   output_f(0x0000);
   output_g(0x0000);
   
   
   output_high(LED);
   delay_ms(1000);
   output_low(LED);
   delay_ms(1000);
   output_high(LED);
   delay_ms(1000);
   output_low(LED);
   delay_ms(1000);
   output_high(LED);
   delay_ms(1000);
   output_low(LED);
   delay_ms(1000);
   
   
   
   int chSet;
   
   while(!input(buton))
   
   output_high(LED);
   output_LOW(STRT); // START High aktif, Burada Pasif konuma al?n?yor.
   
  
   /*Power Up Squence Timing Diagram  bknz: syf 77*/
   
   output_high(RST);  // Reset 0'da aktif, ?uan pasif konuma al?yoruz.
   delay_ms(1000);     // Cihaz?n haz?r olmas? için bekleme veriyoruz. 
   output_low(RST);   // Reset 0'da aktif, ?uan aktif konuma al?yoruz.
   delay_us(10);
   
   output_high(RST);
   output_high(PWDN); // power Down 0'da aktif, ?uan pasif konuma al?yoruz
   delay_ms(1000);    // 
   
   output_HIGH(CS);   // CS low aktif, Burada Pasif konuma al?n?yor.
   
   
   /****?ssue Reset Pulse */
   output_low(RST);   // Reset 0'da aktif, ?uan aktif konuma al?yoruz.
   delay_us(1);       // Reset için Trst süresi min 2 Tclk olarak verilmi?.
   output_high(RST);  // Reset 0'da aktif, ?uan pasif konuma al?yoruz.
   delay_us(10);
   /****************************/
     
   send_command(SDATAC); // Send SDATAC Command (Stop Read Data Continuously mode) 
   delay_ms(10);
 
   chSet=read_byte(READ | ID);
   write_byte(GPIO,0x00);
   
   write_byte(CONFIG1,SAMP_500_SPS); 
 //  write_byte(CONFIG2,0xA0);
   delay_ms(1000);
   write_byte(CONFIG2, 0x30); //Actives test signal. Comment this line for normal electrodes
   
   output_low(LED);
   //chSet = read_byte(CONFIG1);   
     chSet = read_byte(CONFIG2);
   // Output_high(STRT); // start reading
   
   for (int j = 1; j <= gMaxChan ;j++) {
      write_byte(CHnSET + j, 0x00); //For test signal 0x05. For normal electrodes 0x00
   }
   // Start
   
   delay_ms(150);

   //detect active channels
   gNumActiveChan = 0;
   for (int i = 1; i <= gMaxChan; i++) 
    {
      delay_us(1); 
      chSet = read_byte(CHnSET + i);
      gActiveChan[i] = ((chSet & 7) != SHORTED);                // SHORTED = 0x01
      if ( (chSet & 7) != SHORTED) gNumActiveChan++; 
    }
   
   
    //send_command(RDATAC); // can't read registers when in rdatac mode! 
    
   usb_init();                      
   usb_task();                      
   usb_wait_for_enumeration();         //Cihaz, haz?r olana kadar bekle
  output_low(LED);
   while(usb_enumerated())
   {
   for(;;)
   { //  usb_put_packet(UcNokta1, gond_paket,3, USB_DTS_TOGGLE);
 if(usb_kbhit(1))             //E?er pc'den yeni bir paket geldiyse
         { usb_get_packet(UcNokta1, paket, 5); //paketi oku 
                  switch(Komut)              // Paketin ilk eleman?ndaki komutu oku ve ilgili göreve git
                  { 
fonsiyonlar }


ayarlardan neresi eksik yanlış yada compiler a göre değişmeli.
Code'm mu oturturum !

Voltajcı

Her satırın harcadığı bir süre var diye biliyorum, dolayısı ile 1 saniye  diğer satırların işlem süresi

int32

CCS'in güncellenmesiyle zaman kayması gibi bir problem olmaması lazım. Devredeki osilatörü kontrol etmelisin. Osilatör sorununa benziyor.

RaMu

Sorularınıza hızlı cevap alın: http://www.picproje.org/index.php/topic,57135.0.html

Okan AKÇA

Ccs güncellemelerde bu durum oluyor. Silip yeniden yükleyin

ehliseyf

#5
Alıntı yapılan: Voltajcı - 12 Ekim 2016, 16:28:19
Her satırın harcadığı bir süre var diye biliyorum, dolayısı ile 1 saniye  diğer satırların işlem süresi
Hocam aynı süre önceden de vardı. Haklısınız bir süre kaybı oluyor. 1 sn dediğiniz tam 1 sn olmuyor ama bu denli büyük sapmalar komut işlemeden ötürü olmasa gerek. Osilatör ile ilgili bir sorun var sanırım.

mesaj birleştirme:: 14 Ekim 2016, 00:02:41

Alıntı yapılan: RaMu - 12 Ekim 2016, 20:32:04
#use delay(clock=48MHz, crystal=20MHz, USB_FULL)


https://www.picproje.org/index.php/topic,59489.msg460551.html#msg460551
Hocam kodu derlemedi. Hatta usb_Full bölümünü sildim onu  da derlemedi.
Alıntı yapılan: Okan AKÇA - 12 Ekim 2016, 20:47:46
Ccs güncellemelerde bu durum oluyor. Silip yeniden yükleyin
Sorunsuz bir sürüm önerebilir misiniz ?

mesaj birleştirme:: 13 Ekim 2016, 10:03:25

Alıntı yapılan: int32 - 12 Ekim 2016, 18:07:38
CCS'in güncellenmesiyle zaman kayması gibi bir problem olmaması lazım. Devredeki osilatörü kontrol etmelisin. Osilatör sorununa benziyor.
Osilatör fikrinize katılıyorum hocam ama daha önce başıma gelmedi tecrübesiz kaldım.
Code'm mu oturturum !

esensoy

En tehlikeli an "zafer" anıdır.

ehliseyf

#7
Alıntı yapılan: esensoy - 13 Ekim 2016, 10:27:25
FUSES HSPLL olmalı,
Hocam Header dosyasında ayar bulunmuyor. 24FJ256GB110.h olarak pic c nin içinde bulunan dosyayı kullanıyorum. Derleme esnasında hata alıyorum.
#nolist
//////// Program memory: 87548x24  Data RAM: 16384  Stack: 31
//////// I/O: 85   Analog Pins: 16
//////// Fuses: WPOSTS1,WPOSTS2,WPOSTS3,WPOSTS4,WPOSTS5,WPOSTS6,WPOSTS7
//////// Fuses: WPOSTS8,WPOSTS9,WPOSTS10,WPOSTS11,WPOSTS12,WPOSTS13,WPOSTS14
//////// Fuses: WPOSTS15,WPOSTS16,WDT32,WDT128,NOWINDIS,WINDIS,NOWDT,WDT
//////// Fuses: ICSP3,ICSP2,ICSP1,DEBUG,NODEBUG,WRT,NOWRT,PROTECT,NOPROTECT
//////// Fuses: NOJTAG,JTAG,EC,XT,HS,NOPR,NODISUVREG,DISUVREG,NOIOL1WAY
//////// Fuses: IOL1WAY,OSCIO,NOOSCIO,CKSFSM,CKSNOFSM,NOCKSFSM,FRC,FRC_PLL
//////// Fuses: PR,PR_PLL,SOSC,LPRC,FRC_PS,PLL1,PLL2,PLL3,PLL4,PLL5,PLL6
//////// Fuses: PLL10,PLL12,NOIESO,IESO,NOWPFP,WPFP,NOWPDIS,WPDIS,WPCFG
//////// Fuses: NOWPCFG,WPBEG,WPEND
////////
Code'm mu oturturum !

Murat Mert

ccs c nin son versiyonlarından birisini yüklemiştim derliyor fakat çalışmıyordu. Kod, kart aynıydı 3-4 saat kafayı yedirtti. Silip eski versiyonu kurdum Bir şey yok gibi çalıştı. Bazen yeni versiyonlarda beklemek lazım.
mert07

esensoy

#use delay(clock=48MHz,crystal=20000000, USB_FULL)

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES WINDIS                   //Watch Dog Timer in non-Window mode
#FUSES NOWRT                    //Program memory not write protected
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOJTAG                   //JTAG disabled
#FUSES DISUVREG                 //Internal USB 3.3V Regulator disabled
#FUSES IOL1WAY                  //Allows only one reconfiguration of peripheral pins
#FUSES NOOSCIO                  //OSC2 is clock output
#FUSES CKSFSM                   //Clock Switching is enabled, fail Safe clock monitor is enabled
#FUSES IESO                     //Internal External Switch Over mode enabled
#FUSES WPFP                     //Write/Erase Protect Page Start/End Location, set to last page or use WPFP=x to set page
#FUSES WPDIS                    //All Flash memory may be erased or written
#FUSES NOWPCFG                  //Configuration Words page is not erase/write-protected
#FUSES WPEND                    //Flash pages WPFP to Configuration Words page are write/erase protected


bu şekilde yazıp dener misin,
başka birşey yazma
En tehlikeli an "zafer" anıdır.

ehliseyf

Alıntı yapılan: esensoy - 13 Ekim 2016, 12:37:58
#use delay(clock=48MHz,crystal=20000000, USB_FULL)

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES WINDIS                   //Watch Dog Timer in non-Window mode
#FUSES NOWRT                    //Program memory not write protected
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOJTAG                   //JTAG disabled
#FUSES DISUVREG                 //Internal USB 3.3V Regulator disabled
#FUSES IOL1WAY                  //Allows only one reconfiguration of peripheral pins
#FUSES NOOSCIO                  //OSC2 is clock output
#FUSES CKSFSM                   //Clock Switching is enabled, fail Safe clock monitor is enabled
#FUSES IESO                     //Internal External Switch Over mode enabled
#FUSES WPFP                     //Write/Erase Protect Page Start/End Location, set to last page or use WPFP=x to set page
#FUSES WPDIS                    //All Flash memory may be erased or written
#FUSES NOWPCFG                  //Configuration Words page is not erase/write-protected
#FUSES WPEND                    //Flash pages WPFP to Configuration Words page are write/erase protected


bu şekilde yazıp dener misin,
başka birşey yazma
Hocam bu şekilde derleme yapmıyor. *** Error 99 "Main.c" Line 22(5,51): Option invalid   No PLL Option
Böyle bir hata veriyor.

mesaj birleştirme:: 13 Ekim 2016, 14:17:33

Alıntı yapılan: Murat Mert - 13 Ekim 2016, 12:13:32
ccs c nin son versiyonlarından birisini yüklemiştim derliyor fakat çalışmıyordu. Kod, kart aynıydı 3-4 saat kafayı yedirtti. Silip eski versiyonu kurdum Bir şey yok gibi çalıştı. Bazen yeni versiyonlarda beklemek lazım.
Eski kullandığım versiyonları arıyorum. Bulup onları yükleyeceğim.
Code'm mu oturturum !

RaMu

Sorularınıza hızlı cevap alın: http://www.picproje.org/index.php/topic,57135.0.html