- Messaggi: 27
- Ringraziamenti ricevuti 1
convertitore UART-USB basato su pic 18f4550
- aimofederico
- Autore della discussione
- Giovane Utente
cmq il problema è il seguente :
1) sono andato sul sito www.droids.it/cmsvb4/content....cdc-stack-v2.7
2) ho scaricato il sorgente a fondo pagina www.droids.it/downloads/USB_Stack_v2.7_CDC.zip
3) volevo adattare il codice preso da www.droids.it/cmsvb4/content....cdc-stack-v2.7 in pratica solo il file HardwareProfile - PICDEM FSUSB.h per poterlo adattare alla mia scheda basata su pic 18f4550 la quale sul port B ha i led e sul porto C ha i fili per la seriale (pin 7-6) e i pin usb (5-4) e sul porto A ha 2 interruttori (pin 4-5) e 2 pin sono per la seriale per la sincronizzazione (1-2)...
è giusto scrivere cosi?
codice:
/********************************************************************
FileName: HardwareProfile - PICDEM FSUSB.h
Dependencies: See INCLUDES section
Processor: PIC18 USB Microcontrollers
Hardware: PICDEM FSUSB
Compiler: Microchip C18
Company: Microchip Technology, Inc.
Software License Agreement:
The software supplied herewith by Microchip Technology Incorporated
(the “Company”) for its PIC® Microcontroller is intended and
supplied to you, the Company’s customer, for use solely and
exclusively on Microchip PIC Microcontroller products. The
software is owned by the Company and/or its supplier, and is
protected under applicable copyright laws. All rights are reserved.
Any use in violation of the foregoing restrictions may subject the
user to criminal sanctions under applicable laws, as well as to
civil liability for the breach of the terms and conditions of this
license.
THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
********************************************************************
File Description:
Change History:
Rev Date Description
1.0 11/19/2004 Initial release
2.1 02/26/2007 Updated for simplicity and to use common
coding style
2.3 09/15/2008 Broke out each hardware platform into its own
"HardwareProfile - xxx.h" file
********************************************************************/
#ifndef HARDWARE_PROFILE_PICDEM_FSUSB_H
#define HARDWARE_PROFILE_PICDEM_FSUSB_H
/*******************************************************************/
/******** USB stack hardware selection options *********************/
/*******************************************************************/
//This section is the set of definitions required by the MCHPFSUSB
// framework. These definitions tell the firmware what mode it is
// running in, and where it can find the results to some information
// that the stack needs.
//These definitions are required by every application developed with
// this revision of the MCHPFSUSB framework. Please review each
// option carefully and determine which options are desired/required
// for your application.
//The PICDEM FS USB Demo Board platform supports the USE_SELF_POWER_SENSE_IO
//and USE_USB_BUS_SENSE_IO features. Uncomment the below line(s) if
//it is desireable to use one or both of the features.
//#define USE_SELF_POWER_SENSE_IO
#define tris_self_power TRISAbits.TRISA2 // Input
#if defined(USE_SELF_POWER_SENSE_IO)
#define self_power PORTAbits.RA2
#else
#define self_power 1
#endif
//#define USE_USB_BUS_SENSE_IO
#define tris_usb_bus_sense TRISAbits.TRISA1 // Input
#if defined(USE_USB_BUS_SENSE_IO)
#define USB_BUS_SENSE PORTAbits.RA1
#else
#define USB_BUS_SENSE 1
#endif
//Uncomment the following line to make the output HEX of this
// project work with the MCHPUSB Bootloader
//#define PROGRAMMABLE_WITH_USB_MCHPUSB_BOOTLOADER
//Uncomment the following line to make the output HEX of this
// project work with the HID Bootloader
#define PROGRAMMABLE_WITH_USB_HID_BOOTLOADER
/*******************************************************************/
/*******************************************************************/
/*******************************************************************/
/******** Application specific definitions *************************/
/*******************************************************************/
/*******************************************************************/
/*******************************************************************/
/** Board definition ***********************************************/
//These defintions will tell the main() function which board is
// currently selected. This will allow the application to add
// the correct configuration bits as wells use the correct
// initialization functions for the board. These defitions are only
// required in the stack provided demos. They are not required in
// final application design.
#define DEMO_BOARD PICDEM_FS_USB
#define PICDEM_FS_USB
#define CLOCK_FREQ 48000000
/** LED ************************************************************/
#define mInitAllLEDs() LATB &= 0xF0; TRISB &= 0xF0;
#define mLED_1 LATBbits.LATB0
#define mLED_2 LATBbits.LATB1
#define mLED_3 LATBbits.LATB2
#define mLED_4 LATBbits.LATB3
#define mGetLED_1() mLED_1
#define mGetLED_2() mLED_2
#define mGetLED_3() mLED_3
#define mGetLED_4() mLED_4
#define mLED_1_On() mLED_1 = 1;
#define mLED_2_On() mLED_2 = 1;
#define mLED_3_On() mLED_3 = 1;
#define mLED_4_On() mLED_4 = 1;
#define mLED_1_Off() mLED_1 = 0;
#define mLED_2_Off() mLED_2 = 0;
#define mLED_3_Off() mLED_3 = 0;
#define mLED_4_Off() mLED_4 = 0;
#define mLED_1_Toggle() mLED_1 = !mLED_1;
#define mLED_2_Toggle() mLED_2 = !mLED_2;
#define mLED_3_Toggle() mLED_3 = !mLED_3;
#define mLED_4_Toggle() mLED_4 = !mLED_4;
/** SWITCH *********************************************************/
#define mInitAllSwitches() TRISAbits.TRISA4=1;TRISAbits.TRISA5=1;
#define mInitSwitch2() TRISAbits.TRISA4=1;
#define mInitSwitch3() TRISAbits.TRISA5=1;
#define sw2 PORTAbits.RA4
#define sw3 PORTAbits.RA5
/** RS 232 lines ****************************************************/
#define UART_TRISTx TRISCbits.TRISC6
#define UART_TRISRx TRISCbits.TRISC7
#define UART_Tx PORTCbits.RC6
#define UART_Rx PORTCbits.RC7
#define UART_TRISRTS TRISAbits.TRISA1
#define UART_RTS PORTAbits.RA1
#define UART_TRISDTR TRISAbits.TRISA2
#define UART_DTR PORTAbits.RA2
#define UART_ENABLE RCSTAbits.SPEN
/** USB external transceiver interface (optional) ******************/
/*
#define tris_usb_vpo TRISBbits.TRISB3 // Output
#define tris_usb_vmo TRISBbits.TRISB2 // Output
#define tris_usb_rcv TRISAbits.TRISA4 // Input
#define tris_usb_vp TRISCbits.TRISC5 // Input
#define tris_usb_vm TRISCbits.TRISC4 // Input
#define tris_usb_oe TRISCbits.TRISC1 // Output
#define tris_usb_suspnd TRISAbits.TRISA3 // Output
*/
/** I/O pin definitions ********************************************/
#define INPUT_PIN 1
#define OUTPUT_PIN 0
#endif //HARDWARE_PROFILE_PICDEM_FSUSB_H
è giusto? ho dimenticato qualcosa o fatto qualche errore, la scheda è realizzata su 1000fori quindi posso modificarla.
il fatto è che volevo ragruppare gli ingressi su il porto A le uscite sul porto B
e usare il porto C per la seriale e la usb.
grazie
Si prega Accesso o Crea un account a partecipare alla conversazione.
- shinshi
- Elit Utente
- Messaggi: 293
- Ringraziamenti ricevuti 29
Se non sbaglio il progetto che hai scaricato e vuoi modificare è a sua volta una modifica dello stack USB CDC contenuto nel Microchip Libraries for Applications.
Personalmente non ho mai modificato il file HardwareProfile - PICDEM FSUSB.h (a parte in caso si utilizzi il bootloader) non credo sia necessario in quanto contiene solo define.
Ti consiglio di leggerti la guida di Mauro Laurenti "Leggere e Scrivere dati via USB Emulazione porta seriale (Classe CDC)" e scaricare direttamente la nuova Microchip Libraries for Applications.
Saluti
Luca
Si prega Accesso o Crea un account a partecipare alla conversazione.
effettivamente ti consiglio anche io di partire direttamente dallo stack Microchip e non uno modificato e proveniente da quello Microchip.
Una guida la trovi nel seguente tutorial , ma controlla anche il progetto Freedom Light e EasyUSB .
Saluti,
Mauro
Si prega Accesso o Crea un account a partecipare alla conversazione.
- aimofederico
- Autore della discussione
- Giovane Utente
- Messaggi: 27
- Ringraziamenti ricevuti 1
infatti ora con il mio profilo hw funziona correttamente su pic18f4550.
ora volevo però compilarlo per 18f2550 perchè ho già una scheda pronta con tale processore, quindi ho modificato la righa
il file HardwareProfile - PICDEM FSUSB (2).h è il seguente :
il fatto è che quando compilo mi da il seguente errore
il il 4550 non è il fratello maggiore del 2550 ?
come posso risolvere questo problema?
grazie mille
Si prega Accesso o Crea un account a partecipare alla conversazione.
- aimofederico
- Autore della discussione
- Giovane Utente
- Messaggi: 27
- Ringraziamenti ricevuti 1
aimofederico ha scritto: ciao vi ringrazio per i vostri consigli, si esatto ieri infatti ho fatto come voi consigliavate.
infatti ora con il mio profilo hw funziona correttamente su pic18f4550.
ora volevo però compilarlo per 18f2550 perchè ho già una scheda pronta con tale processore, quindi ho modificato la righain modo che mi possa compilare anche per 18f2550 quando lo seleziono dal menu configure>Select device.Code:#if defined(__18CXX) #if (defined(__18F4550)||defined(__18F2550))//#if defined(__18F4550) #include "HardwareProfile - PICDEM FSUSB (2).h"
il file HardwareProfile - PICDEM FSUSB (2).h è il seguente :Code:/******************************************************************** FileName: HardwareProfile - PICDEM FSUSB.h Dependencies: See INCLUDES section Processor: PIC18 USB Microcontrollers Hardware: PICDEM FSUSB Compiler: Microchip C18 Company: Microchip Technology, Inc. Software License Agreement: The software supplied herewith by Microchip Technology Incorporated (the “Company”) for its PIC® Microcontroller is intended and supplied to you, the Company’s customer, for use solely and exclusively on Microchip PIC Microcontroller products. The software is owned by the Company and/or its supplier, and is protected under applicable copyright laws. All rights are reserved. Any use in violation of the foregoing restrictions may subject the user to criminal sanctions under applicable laws, as well as to civil liability for the breach of the terms and conditions of this license. THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. ******************************************************************** File Description: Change History: Rev Date Description 1.0 11/19/2004 Initial release 2.1 02/26/2007 Updated for simplicity and to use common coding style 2.3 09/15/2008 Broke out each hardware platform into its own "HardwareProfile - xxx.h" file ********************************************************************/ #ifndef HARDWARE_PROFILE_PICDEM_FSUSB_H #define HARDWARE_PROFILE_PICDEM_FSUSB_H /*******************************************************************/ /******** USB stack hardware selection options *********************/ /*******************************************************************/ //This section is the set of definitions required by the MCHPFSUSB // framework. These definitions tell the firmware what mode it is // running in, and where it can find the results to some information // that the stack needs. //These definitions are required by every application developed with // this revision of the MCHPFSUSB framework. Please review each // option carefully and determine which options are desired/required // for your application. //The PICDEM FS USB Demo Board platform supports the USE_SELF_POWER_SENSE_IO //and USE_USB_BUS_SENSE_IO features. Uncomment the below line(s) if //it is desireable to use one or both of the features. //#define USE_SELF_POWER_SENSE_IO #define tris_self_power TRISAbits.TRISA2 // Input #if defined(USE_SELF_POWER_SENSE_IO) #define self_power PORTAbits.RA2 //non so se metterlo a null per avere il porto a libero #else #define self_power 1 #endif //#define USE_USB_BUS_SENSE_IO #define tris_usb_bus_sense TRISAbits.TRISA1 // Input #if defined(USE_USB_BUS_SENSE_IO) #define USB_BUS_SENSE PORTAbits.RA1 //non so se metterlo a null per avere il porto a libero #else #define USB_BUS_SENSE 1 #endif //Uncomment the following line to make the output HEX of this // project work with the MCHPUSB Bootloader //#define PROGRAMMABLE_WITH_USB_MCHPUSB_BOOTLOADER //Uncomment the following line to make the output HEX of this // project work with the HID Bootloader #define PROGRAMMABLE_WITH_USB_HID_BOOTLOADER /*******************************************************************/ /*******************************************************************/ /*******************************************************************/ /******** Application specific definitions *************************/ /*******************************************************************/ /*******************************************************************/ /*******************************************************************/ /** Board definition ***********************************************/ //These defintions will tell the main() function which board is // currently selected. This will allow the application to add // the correct configuration bits as wells use the correct // initialization functions for the board. These defitions are only // required in the stack provided demos. They are not required in // final application design. #define DEMO_BOARD PICDEM_FS_USB #define PICDEM_FS_USB #define CLOCK_FREQ 48000000 #define GetSystemClock() (CLOCK_FREQ) /** LED ************************************************************/ #define mInitAllLEDs() LATB &= 0xF0; TRISB &= 0xF0; #define mLED_1 LATBbits.LATB0 #define mLED_2 LATBbits.LATB1 #define mLED_3 LATBbits.LATB2 #define mLED_4 LATBbits.LATB3 #define mGetLED_1() mLED_1 #define mGetLED_2() mLED_2 #define mGetLED_3() mLED_3 #define mGetLED_4() mLED_4 #define mLED_1_On() mLED_1 = 1; #define mLED_2_On() mLED_2 = 1; #define mLED_3_On() mLED_3 = 1; #define mLED_4_On() mLED_4 = 1; #define mLED_1_Off() mLED_1 = 0; #define mLED_2_Off() mLED_2 = 0; #define mLED_3_Off() mLED_3 = 0; #define mLED_4_Off() mLED_4 = 0; #define mLED_1_Toggle() mLED_1 = !mLED_1; #define mLED_2_Toggle() mLED_2 = !mLED_2; #define mLED_3_Toggle() mLED_3 = !mLED_3; #define mLED_4_Toggle() mLED_4 = !mLED_4; /** SWITCH *********************************************************/ #define mInitAllSwitches() TRISAbits.TRISA0=1;TRISAbits.TRISA1=1; #define mInitSwitch2() TRISAbits.TRISA0=1; #define mInitSwitch3() TRISAbits.TRISA1=1; #define sw2 PORTAbits.RA0 #define sw3 PORTAbits.RA1 /** RS 232 lines ****************************************************/ #define UART_TRISTx TRISCbits.TRISC6 #define UART_TRISRx TRISCbits.TRISC7 #define UART_Tx PORTCbits.RC6 #define UART_Rx PORTCbits.RC7 #define UART_TRISRTS TRISAbits.TRISA2//=0; #define UART_RTS PORTAbits.RA2 #define UART_TRISDTR TRISAbits.TRISA3//=1; #define UART_DTR PORTAbits.RA3 #define UART_ENABLE RCSTAbits.SPEN /** USB external transceiver interface (optional) ******************/ /* #define tris_usb_vpo TRISBbits.TRISB3 // Output #define tris_usb_vmo TRISBbits.TRISB2 // Output #define tris_usb_rcv TRISAbits.TRISA4 // Input #define tris_usb_vp TRISCbits.TRISC5 // Input #define tris_usb_vm TRISCbits.TRISC4 // Input #define tris_usb_oe TRISCbits.TRISC1 // Output #define tris_usb_suspnd TRISAbits.TRISA3 // Output */ /** I/O pin definitions ********************************************/ #define INPUT_PIN 1 #define OUTPUT_PIN 0 #endif //HARDWARE_PROFILE_PICDEM_FSUSB_H
il fatto è che quando compilo mi da il seguente errore
Code:---------------------------------------------------------------------- Release build of project `C:\Program Files (x86)\Microchip\Microchip Solutions v2011-07-14\USB\Device - CDC - Serial Emulator - Copia\Firmware\USB Device - CDC - Serial Emulator - C18 - PICDEM FSUSB.mcp' started. Language tool versions: mpasmwin.exe v5.40, mplink.exe v4.38, mcc18.exe v3.37.01, mplib.exe v4.38 Tue May 07 10:58:10 2013 ---------------------------------------------------------------------- Clean: Deleting intermediary and output files. Clean: Deleted file "C:\Program Files (x86)\Microchip\Microchip Solutions v2011-07-14\USB\Device - CDC - Serial Emulator - Copia\Firmware\Objects\FSUSB\usb_descriptors.o". Clean: Deleted file "C:\Program Files (x86)\Microchip\Microchip Solutions v2011-07-14\USB\Device - CDC - Serial Emulator - Copia\Firmware\Objects\FSUSB\main.o". Clean: Deleted file "C:\Program Files (x86)\Microchip\Microchip Solutions v2011-07-14\USB\Device - CDC - Serial Emulator - Copia\Firmware\Objects\FSUSB\usb_function_cdc.o". Clean: Deleted file "C:\Program Files (x86)\Microchip\Microchip Solutions v2011-07-14\USB\Device - CDC - Serial Emulator - Copia\Firmware\Objects\FSUSB\usb_device.o". Clean: Deleted file "C:\Program Files (x86)\Microchip\Microchip Solutions v2011-07-14\USB\Device - CDC - Serial Emulator - Copia\Firmware\USB Device - CDC - Serial Emulator - C18 - PICDEM FSUSB.cof". Clean: Deleted file "C:\Program Files (x86)\Microchip\Microchip Solutions v2011-07-14\USB\Device - CDC - Serial Emulator - Copia\Firmware\USB Device - CDC - Serial Emulator - C18 - PICDEM FSUSB.hex". Clean: Done. Executing: "C:\Program Files (x86)\Microchip\mplabc18\v3.37.01\bin\mcc18.exe" -p=18F2550 /i"C:\Program Files (x86)\Microchip\mplabc18\v3.37.01\h" -I"C:\Program Files\Microchip\mplabc18\v3.38\h" -I"." -I"..\..\..\Microchip\include" "usb_descriptors.c" -fo=".\Objects\FSUSB\usb_descriptors.o" -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa- Executing: "C:\Program Files (x86)\Microchip\mplabc18\v3.37.01\bin\mcc18.exe" -p=18F2550 /i"C:\Program Files (x86)\Microchip\mplabc18\v3.37.01\h" -I"C:\Program Files\Microchip\mplabc18\v3.38\h" -I"." -I"..\..\..\Microchip\include" "main.c" -fo=".\Objects\FSUSB\main.o" -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa- Executing: "C:\Program Files (x86)\Microchip\mplabc18\v3.37.01\bin\mcc18.exe" -p=18F2550 /i"C:\Program Files (x86)\Microchip\mplabc18\v3.37.01\h" -I"C:\Program Files\Microchip\mplabc18\v3.38\h" -I"." -I"..\..\..\Microchip\include" "..\..\..\Microchip\USB\CDC Device Driver\usb_function_cdc.c" -fo=".\Objects\FSUSB\usb_function_cdc.o" -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa- Executing: "C:\Program Files (x86)\Microchip\mplabc18\v3.37.01\bin\mcc18.exe" -p=18F2550 /i"C:\Program Files (x86)\Microchip\mplabc18\v3.37.01\h" -I"C:\Program Files\Microchip\mplabc18\v3.38\h" -I"." -I"..\..\..\Microchip\include" "..\..\..\Microchip\USB\usb_device.c" -fo=".\Objects\FSUSB\usb_device.o" -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa- Executing: "C:\Program Files (x86)\Microchip\mplabc18\v3.37.01\bin\mplink.exe" /p18F2550 /l"C:\Program Files (x86)\Microchip\mplabc18\v3.37.01\lib" "rm18f4550 - HID Bootload.lkr" "Objects\FSUSB\usb_descriptors.o" "Objects\FSUSB\main.o" "Objects\FSUSB\usb_function_cdc.o" "Objects\FSUSB\usb_device.o" /u_CRUNTIME /z__MPLAB_BUILD=1 /o"USB Device - CDC - Serial Emulator - C18 - PICDEM FSUSB.cof" /M"USB Device - CDC - Serial Emulator - C18 - PICDEM FSUSB.map" /W MPLINK 4.38, Linker Copyright (c) 1998-2010 Microchip Technology Inc. Error - processor types do not agree across all input files. Errors : 1 Link step failed. ---------------------------------------------------------------------- Release build of project `C:\Program Files (x86)\Microchip\Microchip Solutions v2011-07-14\USB\Device - CDC - Serial Emulator - Copia\Firmware\USB Device - CDC - Serial Emulator - C18 - PICDEM FSUSB.mcp' failed. Language tool versions: mpasmwin.exe v5.40, mplink.exe v4.38, mcc18.exe v3.37.01, mplib.exe v4.38 Tue May 07 10:58:22 2013 ---------------------------------------------------------------------- BUILD FAILED
il il 4550 non è il fratello maggiore del 2550 ?
come posso risolvere questo problema?
grazie mille
ho notato che se compilo per 4550 (non da errori e funziona correttamente),ottengo il seguente output:
ho notato che la le differenze sono :
per il 18f2550
e per il 18f4550
che sia rm18f4550 - HID Bootload.lkr la causa del problema ?
come posso risolverlo ?
graziemille a tutti
Si prega Accesso o Crea un account a partecipare alla conversazione.
Registrati al sito
Accedi a tutte le risorse e articoli non visibili pubblicamente, puoi registrarti con pochi passi.
Forum - Ultimi messaggi
-
- Freedom III e compilazioni fallite
- da Black
-
- MODULO GSM SIM900A
- da FABRIZIO
-
- LTerminal - nuove funzioni
- da Mauro Laurenti
-
- Aggiornamento sito completato
- da Mauro Laurenti
-
- registro a scorrimento PIPO in cascata
- da Mauro Laurenti