PIC e USB. Come iniziare?

Tipologie, strumenti di sviluppo, hardware e progetti

Moderatore: Foto UtentePaolino

Avatar utente
Foto UtenteShockwaver
770 1 5 11
Expert
Expert
Messaggi: 859
Iscritto il: 3 mar 2010, 17:56
0
voti

[71] Re: PIC e USB. Come iniziare?

Messaggioda Foto UtenteShockwaver » 29 dic 2010, 23:41

?%
Ma allora c'è qualcosa che mi sfugge tremendamente:
DS dello Starter Kit. A pagg 15, 17, 18 si vede che l'USB è attaccata al PIC18F4550 (è un QFN)

DS dello Starter Kit II. A pagg 17, 20, 21 c'è scritto che l'USB è attaccata al PIC32MX440F572H

Cosa non sto capendo? °#^

Monto un PIC32MX460F256L
Fuses presi pari pari dal main (con la mia modifica)

Codice: Seleziona tutto

#if defined(PICDEM_FS_USB)      // Configuration bits for PICDEM FS USB Demo Board (based on PIC18F4550)
        #pragma config PLLDIV   = 5         // (20 MHz crystal on PICDEM FS USB board)
        #pragma config CPUDIV   = OSC1_PLL2   
        #pragma config USBDIV   = 2         // Clock source from 96MHz PLL/2
        #pragma config FOSC     = HSPLL_HS
        #pragma config FCMEN    = OFF
        #pragma config IESO     = OFF
        #pragma config PWRT     = OFF
        #pragma config BOR      = ON
        #pragma config BORV     = 3
        #pragma config VREGEN   = ON      //USB Voltage Regulator
        #pragma config WDT      = OFF
        #pragma config WDTPS    = 32768
        #pragma config MCLRE    = ON
        #pragma config LPT1OSC  = OFF
        #pragma config PBADEN   = OFF
//      #pragma config CCP2MX   = ON
        #pragma config STVREN   = ON
        #pragma config LVP      = OFF
//      #pragma config ICPRT    = OFF       // Dedicated In-Circuit Debug/Programming
        #pragma config XINST    = OFF       // Extended Instruction Set
        #pragma config CP0      = OFF
        #pragma config CP1      = OFF
//      #pragma config CP2      = OFF
//      #pragma config CP3      = OFF
        #pragma config CPB      = OFF
//      #pragma config CPD      = OFF
        #pragma config WRT0     = OFF
        #pragma config WRT1     = OFF
//      #pragma config WRT2     = OFF
//      #pragma config WRT3     = OFF
        #pragma config WRTB     = OFF       // Boot Block Write Protection
        #pragma config WRTC     = OFF
//      #pragma config WRTD     = OFF
        #pragma config EBTR0    = OFF
        #pragma config EBTR1    = OFF
//      #pragma config EBTR2    = OFF
//      #pragma config EBTR3    = OFF
        #pragma config EBTRB    = OFF


#elif defined(PIC18F87J50_PIM)            // Configuration bits for PIC18F87J50 FS USB Plug-In Module board
        #pragma config XINST    = OFF      // Extended instruction set
        #pragma config STVREN   = ON         // Stack overflow reset
        #pragma config PLLDIV   = 3         // (12 MHz crystal used on this board)
        #pragma config WDTEN    = OFF         // Watch Dog Timer (WDT)
        #pragma config CP0      = OFF         // Code protect
        #pragma config CPUDIV   = OSC1      // OSC1 = divide by 1 mode
        #pragma config IESO     = OFF         // Internal External (clock) Switchover
        #pragma config FCMEN    = OFF         // Fail Safe Clock Monitor
        #pragma config FOSC     = HSPLL     // Firmware must also set OSCTUNE<PLLEN> to start PLL!
        #pragma config WDTPS    = 32768
//      #pragma config WAIT     = OFF         // Commented choices are
//      #pragma config BW       = 16         // only available on the
//      #pragma config MODE     = MM         // 80 pin devices in the
//      #pragma config EASHFT   = OFF         // family.
        #pragma config MSSPMSK  = MSK5
//      #pragma config PMPMX    = DEFAULT
//      #pragma config ECCPMX   = DEFAULT
        #pragma config CCP2MX   = DEFAULT   

#elif defined(PIC18F46J50_PIM) || defined(PIC18F_STARTER_KIT_1) || defined(PIC18F47J53_PIM)
     #pragma config WDTEN = OFF          //WDT disabled (enabled by SWDTEN bit)
     #pragma config PLLDIV = 3           //Divide by 3 (12 MHz oscillator input)
     #pragma config STVREN = ON            //stack overflow/underflow reset enabled
     #pragma config XINST = OFF          //Extended instruction set disabled
     #pragma config CPUDIV = OSC1        //No CPU system clock divide
     #pragma config CP0 = OFF            //Program memory is not code-protected
     #pragma config OSC = HSPLL          //HS oscillator, PLL enabled, HSPLL used by USB
     //#pragma config T1DIG = ON           //Sec Osc clock source may be selected
     //#pragma config LPT1OSC = OFF        //high power Timer1 mode
     #pragma config FCMEN = OFF          //Fail-Safe Clock Monitor disabled
     #pragma config IESO = OFF           //Two-Speed Start-up disabled
     #pragma config WDTPS = 32768        //1:32768
     #pragma config DSWDTOSC = INTOSCREF //DSWDT uses INTOSC/INTRC as clock
     #pragma config RTCOSC = T1OSCREF    //RTCC uses T1OSC/T1CKI as clock
     #pragma config DSBOREN = OFF        //Zero-Power BOR disabled in Deep Sleep
     #pragma config DSWDTEN = OFF        //Disabled
     #pragma config DSWDTPS = 8192       //1:8,192 (8.5 seconds)
     #pragma config IOL1WAY = OFF        //IOLOCK bit can be set and cleared
     #pragma config MSSP7B_EN = MSK7     //7 Bit address masking
     #pragma config WPFP = PAGE_1        //Write Protect Program Flash Page 0
     #pragma config WPEND = PAGE_0       //Start protection at page 0
     #pragma config WPCFG = OFF          //Write/Erase last page protect Disabled
     #pragma config WPDIS = OFF          //WPFP[5:0], WPEND, and WPCFG bits ignored 
#elif defined(LOW_PIN_COUNT_USB_DEVELOPMENT_KIT)
        //14K50
        #pragma config CPUDIV = NOCLKDIV
        #pragma config USBDIV = OFF
        #pragma config FOSC   = HS
        #pragma config PLLEN  = ON
        #pragma config FCMEN  = OFF
        #pragma config IESO   = OFF
        #pragma config PWRTEN = OFF
        #pragma config BOREN  = OFF
        #pragma config BORV   = 30
//        #pragma config VREGEN = ON
        #pragma config WDTEN  = OFF
        #pragma config WDTPS  = 32768
        #pragma config MCLRE  = OFF
        #pragma config HFOFST = OFF
        #pragma config STVREN = ON
        #pragma config LVP    = OFF
        #pragma config XINST  = OFF
        #pragma config BBSIZ  = OFF
        #pragma config CP0    = OFF
        #pragma config CP1    = OFF
        #pragma config CPB    = OFF
        #pragma config WRT0   = OFF
        #pragma config WRT1   = OFF
        #pragma config WRTB   = OFF
        #pragma config WRTC   = OFF
        #pragma config EBTR0  = OFF
        #pragma config EBTR1  = OFF
        #pragma config EBTRB  = OFF       

#elif defined(EXPLORER_16)
    #if defined(__PIC24FJ256GB110__)
        _CONFIG1( JTAGEN_OFF & GCP_OFF & GWRP_OFF & FWDTEN_OFF & ICS_PGx2)
        _CONFIG2( 0xF7FF & IESO_OFF & FCKSM_CSDCMD & OSCIOFNC_ON & POSCMOD_HS & FNOSC_PRIPLL & PLLDIV_DIV2 & IOL1WAY_ON)
    #elif defined(__PIC24FJ256GB210__)
        _CONFIG1(FWDTEN_OFF & ICS_PGx2 & GWRP_OFF & GCP_OFF & JTAGEN_OFF)
        _CONFIG2(POSCMOD_HS & IOL1WAY_ON & OSCIOFNC_ON & FCKSM_CSDCMD & FNOSC_PRIPLL & PLL96MHZ_ON & PLLDIV_DIV2 & IESO_OFF)
    #elif defined(__PIC24FJ64GB004__)
        _CONFIG1(WDTPS_PS1 & FWPSA_PR32 & WINDIS_OFF & FWDTEN_OFF & ICS_PGx1 & GWRP_OFF & GCP_OFF & JTAGEN_OFF)
        _CONFIG2(POSCMOD_HS & I2C1SEL_PRI & IOL1WAY_OFF & OSCIOFNC_ON & FCKSM_CSDCMD & FNOSC_PRIPLL & PLL96MHZ_ON & PLLDIV_DIV2 & IESO_ON)
        _CONFIG3(WPFP_WPFP0 & SOSCSEL_SOSC & WUTSEL_LEG & WPDIS_WPDIS & WPCFG_WPCFGDIS & WPEND_WPENDMEM)
        _CONFIG4(DSWDTPS_DSWDTPS3 & DSWDTOSC_LPRC & RTCOSC_SOSC & DSBOREN_OFF & DSWDTEN_OFF)
    #elif defined(__32MX460F512L__) || defined(__32MX795F512L__) || defined(__32MX460F256L__) <----Passa questo
        #pragma config UPLLEN   = ON        // USB PLL Enabled
        #pragma config FPLLMUL  = MUL_15        // PLL Multiplier
        #pragma config UPLLIDIV = DIV_2         // USB PLL Input Divider
        #pragma config FPLLIDIV = DIV_2         // PLL Input Divider
        #pragma config FPLLODIV = DIV_1         // PLL Output Divider
        #pragma config FPBDIV   = DIV_1         // Peripheral Clock divisor
        #pragma config FWDTEN   = OFF           // Watchdog Timer
        #pragma config WDTPS    = PS1           // Watchdog Timer Postscale
        #pragma config FCKSM    = CSDCMD        // Clock Switching & Fail Safe Clock Monitor
        #pragma config OSCIOFNC = OFF           // CLKO Enable
        #pragma config POSCMOD  = OFF            // Primary Oscillator
        #pragma config IESO     = OFF           // Internal/External Switch-over
        #pragma config FSOSCEN  = OFF           // Secondary Oscillator Enable (KLO was off)
        #pragma config FNOSC    = FRCPLL        // Oscillator Selection
        #pragma config CP       = OFF           // Code Protect
        #pragma config BWP      = OFF           // Boot Flash Write Protect
        #pragma config PWP      = OFF           // Program Flash Write Protect
        #pragma config ICESEL   = ICS_PGx1      // ICE/ICD Comm Channel Select
        #pragma config DEBUG    = ON            // Background Debugger Enable
    #elif defined(__dsPIC33EP512MU810__)
        _FOSCSEL(FNOSC_FRC);
        _FOSC(FCKSM_CSECMD & OSCIOFNC_OFF & POSCMD_XT);
        _FWDT(FWDTEN_OFF);
    #else
        #error No hardware board defined, see "HardwareProfile.h" and __FILE__
    #endif
#elif defined(PIC24F_STARTER_KIT)
    _CONFIG1( JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF & ICS_PGx2)
    _CONFIG2( 0xF7FF & IESO_OFF & FCKSM_CSDCMD & OSCIOFNC_ON & POSCMOD_HS & FNOSC_PRIPLL & PLLDIV_DIV3 & IOL1WAY_ON)
#elif defined(PIC24FJ256DA210_DEV_BOARD)
    _CONFIG1(FWDTEN_OFF & ICS_PGx2 & GWRP_OFF & GCP_OFF & JTAGEN_OFF)
    _CONFIG2(POSCMOD_HS & IOL1WAY_ON & OSCIOFNC_ON & FCKSM_CSDCMD & FNOSC_PRIPLL & PLL96MHZ_ON & PLLDIV_DIV2 & IESO_OFF)
#elif defined(PIC32_USB_STARTER_KIT)
    #pragma config UPLLEN   = ON        // USB PLL Enabled
    #pragma config FPLLMUL  = MUL_15        // PLL Multiplier
    #pragma config UPLLIDIV = DIV_2         // USB PLL Input Divider
    #pragma config FPLLIDIV = DIV_2         // PLL Input Divider
    #pragma config FPLLODIV = DIV_1         // PLL Output Divider
    #pragma config FPBDIV   = DIV_1         // Peripheral Clock divisor
    #pragma config FWDTEN   = OFF           // Watchdog Timer
    #pragma config WDTPS    = PS1           // Watchdog Timer Postscale
    #pragma config FCKSM    = CSDCMD        // Clock Switching & Fail Safe Clock Monitor
    #pragma config OSCIOFNC = OFF           // CLKO Enable
    #pragma config POSCMOD  = OFF            // Primary Oscillator
    #pragma config IESO     = OFF           // Internal/External Switch-over
    #pragma config FSOSCEN  = OFF           // Secondary Oscillator Enable (KLO was off)
    #pragma config FNOSC    = FRCPLL        // Oscillator Selection
    #pragma config CP       = OFF           // Code Protect
    #pragma config BWP      = OFF           // Boot Flash Write Protect
    #pragma config PWP      = OFF           // Program Flash Write Protect
    #pragma config ICESEL   = ICS_PGx1      // ICE/ICD Comm Channel Select
    #pragma config DEBUG    = ON            // Background Debugger Enable
#else
    #error No hardware board defined, see "HardwareProfile.h" and __FILE__
#endif
Anyone who has never made a mistake has never tried anything new
Two things are infinite: universe and human stupidity, and I'm not sure about the former
You did not really understand something unless you can explain it to your grandmother
A. Einstein

Avatar utente
Foto UtenteTardoFreak
73,9k 8 12 13
-EY Legend-
-EY Legend-
Messaggi: 15754
Iscritto il: 16 dic 2009, 10:10
Località: Torino - 3° pianeta del Sistema Solare
0
voti

[72] Re: PIC e USB. Come iniziare?

Messaggioda Foto UtenteTardoFreak » 30 dic 2010, 9:46

Quelli a cui fai riferimento sono i chip di programmazione e debug!
Gli starter kit del PIC32 non hanno bisogno del debugger esterno (come il PICkit 3 ad esempio) proprio perche' hanno montato sopra un PIC che fa il lavoro di programmazione e debug, infatti il connettore USB a cui sono collegati e' contrassegnato come "DEBUG".
Per i fuses dammi un po' di tempo. Ieri sera ho festeggiato il compleanno, sono ancora ... "fused" ed ho bisogno di qualche oretta per riprendermi dalla sbronz ... ehm ... dalla festa :mrgreen: :mrgreen: :mrgreen:
Appena saro' in grado di analizzarli editero' questo messaggio. :ok:
"La follia sta nel fare sempre la stessa cosa aspettandosi risultati diversi".
"Parla soltanto quando sei sicuro che quello che dirai è più bello del silenzio".
Rispondere è cortesia, ma lasciare l'ultima parola ai cretini è arte.

Avatar utente
Foto UtenteShockwaver
770 1 5 11
Expert
Expert
Messaggi: 859
Iscritto il: 3 mar 2010, 17:56
0
voti

[73] Re: PIC e USB. Come iniziare?

Messaggioda Foto UtenteShockwaver » 30 dic 2010, 11:13

Stica...

A U G U R I!!!!!!!!
:ola: \O-< :U: :U:
Anyone who has never made a mistake has never tried anything new
Two things are infinite: universe and human stupidity, and I'm not sure about the former
You did not really understand something unless you can explain it to your grandmother
A. Einstein

Avatar utente
Foto UtenteTardoFreak
73,9k 8 12 13
-EY Legend-
-EY Legend-
Messaggi: 15754
Iscritto il: 16 dic 2009, 10:10
Località: Torino - 3° pianeta del Sistema Solare
0
voti

[74] Re: PIC e USB. Come iniziare?

Messaggioda Foto UtenteTardoFreak » 30 dic 2010, 11:34

OK, mi sono ripreso, ho guardato bene e, per essere sicuro di quello che scrivo, ho anche provato praticamente la cosa in questo modo:
- Ho utilizzato il PIC32 USB Starter Kit II, quindi con il 795. Non ho altro quindi posso solo fare questo.
- Ho provato il firmware che mi hanno dato insieme allo starter kit cosi' com'e', quindi utilizza il quarzo da 8 MHz collegato all' oscillatore primario FPLLMUL = MUL_20 e funziona.
- Ho cambiato la selzione dell' oscillatore da FNOSC = PRIPLL a FNOSC = FRCPLL e, buona notizia per te, funziona. A quanto pare l' USB non e' poi cosi' schizzinosa, ho imparato qualcosa di nuovo e forse abbiamo eliminato un variabile.
- - Ho provato il firmware contenuto nel Microchip Solutions V2010-10-19 usando "USB Device - CDC - Basic Demo - PIC32 USB Starter Kit II.mcp", quindi utilizza il quarzo da 8 MHz collegato all' oscillatore primario FPLLMUL = MUL_15 e funziona.
- Ho cambiato la selzione dell' oscillatore da FNOSC = PRIPLL a FNOSC = FRCPLL e funziona.

Ora, purtroppo, non saprei cosa aggiungere di altro se non suggerirti di spulciare i sorgenti e, visto che tu DEVI avere selezionato la board EXPLORER 16, di verificare che questa selezione non porti modifiche rispetto a quella dello starter kit. In pratica devi cercare tutte le compilazioni condizionate della definizione defined(EXPLORER_16) e vedere cosa comporta.
Oppure provare a montare sul tuo circuito un 795.

Quindi mi fermo qui, prendo atto dei miei limiti, depongo le armi e ti faccio tanti auguri per il tuo progetto.
"La follia sta nel fare sempre la stessa cosa aspettandosi risultati diversi".
"Parla soltanto quando sei sicuro che quello che dirai è più bello del silenzio".
Rispondere è cortesia, ma lasciare l'ultima parola ai cretini è arte.

Avatar utente
Foto UtenteShockwaver
770 1 5 11
Expert
Expert
Messaggi: 859
Iscritto il: 3 mar 2010, 17:56
0
voti

[75] Re: PIC e USB. Come iniziare?

Messaggioda Foto UtenteShockwaver » 30 dic 2010, 11:55

Grazie x l'aiuto.. torno alla carica.
Spero di non aver bruciato il modulo USB...
Anyone who has never made a mistake has never tried anything new
Two things are infinite: universe and human stupidity, and I'm not sure about the former
You did not really understand something unless you can explain it to your grandmother
A. Einstein

Avatar utente
Foto UtenteTardoFreak
73,9k 8 12 13
-EY Legend-
-EY Legend-
Messaggi: 15754
Iscritto il: 16 dic 2009, 10:10
Località: Torino - 3° pianeta del Sistema Solare
0
voti

[76] Re: PIC e USB. Come iniziare?

Messaggioda Foto UtenteTardoFreak » 1 gen 2011, 17:42

Ultimo dubbio (non so piu' a cosa pensare): I collegamenti a D+ e D- li hai verificati? Sono collegati giusti? Se non lo sono windows, fra le altre cose, non ti riconosce il dispositivo.

BUON ANNO! :D
"La follia sta nel fare sempre la stessa cosa aspettandosi risultati diversi".
"Parla soltanto quando sei sicuro che quello che dirai è più bello del silenzio".
Rispondere è cortesia, ma lasciare l'ultima parola ai cretini è arte.

Avatar utente
Foto UtenteShockwaver
770 1 5 11
Expert
Expert
Messaggi: 859
Iscritto il: 3 mar 2010, 17:56
0
voti

[77] Re: PIC e USB. Come iniziare?

Messaggioda Foto UtenteShockwaver » 2 gen 2011, 14:12

Buon anno!!
Sì verificato decina di volte..
Anche i collegamenti stessi sono buoni..
Anyone who has never made a mistake has never tried anything new
Two things are infinite: universe and human stupidity, and I'm not sure about the former
You did not really understand something unless you can explain it to your grandmother
A. Einstein

Avatar utente
Foto UtenteTardoFreak
73,9k 8 12 13
-EY Legend-
-EY Legend-
Messaggi: 15754
Iscritto il: 16 dic 2009, 10:10
Località: Torino - 3° pianeta del Sistema Solare
0
voti

[78] Re: PIC e USB. Come iniziare?

Messaggioda Foto UtenteTardoFreak » 2 gen 2011, 14:19

Ultima richiesta: quando sarai riuscito a far funzionare tutto l' ambaradan riprendi questo post e scrivi come hai risolto.
Poi fammi un fischio perche' sara' il caso di farci un birretta insieme per festeggiare l' evento. :ok:
"La follia sta nel fare sempre la stessa cosa aspettandosi risultati diversi".
"Parla soltanto quando sei sicuro che quello che dirai è più bello del silenzio".
Rispondere è cortesia, ma lasciare l'ultima parola ai cretini è arte.

Avatar utente
Foto UtenteShockwaver
770 1 5 11
Expert
Expert
Messaggi: 859
Iscritto il: 3 mar 2010, 17:56
0
voti

[79] Re: PIC e USB. Come iniziare?

Messaggioda Foto UtenteShockwaver » 2 gen 2011, 16:30

Ma sicuramente!
Anche perché tra non molto torno a torino :ok:
Anyone who has never made a mistake has never tried anything new
Two things are infinite: universe and human stupidity, and I'm not sure about the former
You did not really understand something unless you can explain it to your grandmother
A. Einstein

Avatar utente
Foto UtenteShockwaver
770 1 5 11
Expert
Expert
Messaggi: 859
Iscritto il: 3 mar 2010, 17:56
0
voti

[80] Re: PIC e USB. Come iniziare?

Messaggioda Foto UtenteShockwaver » 3 gen 2011, 2:57

Scusa ma..
Lo Starter Kit monta un PIC32MX360F512L.. ma allora perché nel codice si fa riferimento al ...460...? :shock:
E poi non capivo una cosa.. Mi dicevi che devo aver selezionato l'EXPLORER_16 e io mi chiedevo, come dovrei farlo e xké? Non posso utilizzare il codice per uno dei 2 starter kit? ?%

Edit: e poi.. lol.. il PIC32MX360F512L non ha neanche il modulo USB!!! °#^
Anyone who has never made a mistake has never tried anything new
Two things are infinite: universe and human stupidity, and I'm not sure about the former
You did not really understand something unless you can explain it to your grandmother
A. Einstein


Torna a “Realizzazioni, interfacciamento e nozioni generali.”