Hallo ! Ich programmiere gerade das µC der Familientyp 8051F320 von Silabs. Ich bin kein Profi sondern ein Anfänger Student. Ich möchte eigentlich Messdaten aus meiner Device erfassen durch die I2C Schnittstelle. Dies habe ich geschafft und konnte die Daten mit meinem Oscilloskop visualisieren. Diese Daten wollte ich aber weiter transportieren zu USB, der dann mit einen GUI Progrämmchen gesteuert werden kann. Dieser Teil schaffe ich bis jetzt nicht. Also brauche Ich ein gutes Beispiel wie ich diese Daten via USB zur an meinem PC schicken bzw vom Device lesen kann. Das ist eine Standard Aufgabe aber ich bin wie gesagt Anfänger. Kann jemand von Euch mir helfen durch ein konkretes Beispiel. Bitte Kochrezept wenn möglich Viele, vielen Dank! Soo
> Das ist eine Standard Aufgabe aber ich bin wie gesagt Anfänger.
Das ist ganz gewiss keine Standardaufgabe. Entweder der Hersteller
deines Controllers bietet dafuer eine Applikation an wo du einiges
uebernehmen kannst, oder du hast die Chance mal so richtig tief und mit
Zeitaufwand in USB einzusteigen. Du darst schliesslich nicht vergessen
das du einmal die Seite des Microcontrollers programmieren musst und
dann nochmal einen Treiber auf PC-Seite. Und dann hast du vielleicht
noch nichtmal ein Diagnosegeraet fuer USB und musst raten warum es nicht
funktioniert.
Und das ist der Grund warum soviele Leute hier die FTDI-ICs einsetzen.
.-)
Olaf
Da gibts einen fertigen IC: USBC Input bei www.rahand.eu. Einfach über I2C ansteuern. Gruß
Oder halt die hier: http://www.codemercs.com/index.php?id=64&L=0 bzw. wenn es handlich verpackt sein soll: http://www.codemercs.com/index.php?id=256&L=0
guest schrieb: > Da gibts einen fertigen IC: USBC Input bei www.rahand.eu. Einfach über > I2C ansteuern. Kommt diese Werbung(?) von einem Gast ab heute jedes Mal, wenn jemand einen µC über USB konnektieren möchte? Wenn Du Dein Bauteil populär machen möchtest: Schreib doch einfach einen Wiki-Artikel. Das wäre aufschlussreicher.
Hallo! Die Daten die ich von der I2C bekomme sollte ich erst verarbeiten um die richtigen Daten via USB an PC zu senden. Also reicht mir nicht nur eine I2C to USB konverter. Also wird ein µC immer gebraucht um diese Daten zu verarbeiten. Hast du Vorschlänge! MFG
Dein µC kann sich also per I2C Daten von irgendwo holen, und diese Daten sollen dann an einen PC weitergesendet werden. Einfache Übung: Nimm eine serielle Schnittstelle. Mit einem Pegelwandler (à la MAX232) kannst Du dann Deinen µC mit dem PC verbinden, und auf dem PC kannst Du ein Terminalprogramm wie z.B. Hyperterminal verwenden, um den vom µC gesendeten Daten zu lauschen. Wenn das geht, ersetze den Pegelwandler durch eine USB-Seriell-Bridge wie den FT232 und schließe die ganze Chose per USB an.
Hi! Ich programmiere gerade weiter die Silabs 8051F320 µC. Ich bekomme vielmals an verschiedenen Stellen diese Felermeldung "not in formal parameter list". Ich habe den Felercode der Keil Compiler angeschaut. Also Hier idt der Link http://www.keil.com/support/man/docs/c51/c51_c132.htm Aber es hilft mir nicht. Habt ihr solche Fehler eine Lösung gefunden? Danke MfG
wo tritt der Fehler auf? Code?? Gruss Robert
Für neue Fragen machst Du bitte einen neuen Thread auf, denn das C-Problem hat nichts mit I2C, USB und PCs zu tun. Ohne den Quelltext zu sehen, der die Fehlermeldung hervorruft, kann Dir kaum geholfen werden. Die Fehlermeldung selbst ist eigentlich sehr eindeutig - Du verwendest eine K&R-Funktionsdefinition wie z.B. hier: int bla(a, b, c) int a, int x, // <- Fehler int y; { ... } Das aber solltest Du nicht tun, K&R-C ist seit 1989 überholt, seitdem sollte so eine Funktion so aussehen: int bla(int a, int b, int c) { ... }
Hi C51 COMPILER V8.18 - SN: Eval Version COPYRIGHT KEIL ELEKTRONIK GmbH 1987 - 2009 *** ERROR C132 IN LINE 124 OF USB I2C T5300 MAIN.C: 'SMB_Write': not in formal parameter list *** ERROR C132 IN LINE 125 OF USB I2C T5300 MAIN.C: 'SMB_Read': not in formal parameter list *** ERROR C132 IN LINE 126 OF USB I2C T5300 MAIN.C: '_T0_Wait_ms': not in formal parameter list *** ERROR C132 IN LINE 130 OF USB I2C T5300 MAIN.C: 'Port_Init_USB': not in formal parameter list *** ERROR C132 IN LINE 131 OF USB I2C T5300 MAIN.C: 'Suspend_Device': not in formal parameter list *** ERROR C132 IN LINE 132 OF USB I2C T5300 MAIN.C: 'Initialize': not in formal parameter list *** ERROR C132 IN LINE 142 OF USB I2C T5300 MAIN.C: 'main': not in formal parameter list DER CODE: #include "compiler_defs.h" #include "C8051f320_defs.h" //#include <C8051F320.h> //#include <stddef.h> #include "USB_API.h" #define INTERRUPT_USBXpress 16 //---------------------------------------------------------------------- ------- // Global CONSTANTS //---------------------------------------------------------------------- ------- // Global Constants for the SMBus communication #define SYSCLK 12000000 // System clock frequency in Hz #define SMB_FREQUENCY 100000 // Target SCL clock rate // This example supports between 10kHz // and 100kHz #define WRITE 0x00 // SMBus WRITE command #define READ 0x01 // SMBus READ command // Device addresses (7 bits, LSB is a don't care) #define SLAVE_ADDR 0x50 // Device address for slave target (T5300) // Status vector - top 4 bits only #define SMB_MTSTA 0xE0 // (MR) start transmitted #define SMB_MTDB 0xC0 // (MT) data byte transmitted #define SMB_MRDB 0x80 // (MR) data byte received // End status vector definition #define NUM_BYTES_WR 1 // Number of bytes to write // Master (µC) -> Slave (T5300) #define NUM_BYTES_RD 5 // Number of bytes to read // Master (µC)<- Slave (T5300) // Global Constants for the USB communication //SBIT(Led1, SFR_P2, 2); // LED='1' means ON //SBIT(Led2, SFR_P2, 3); U8 Out_Packet[8] = {0,0,0,0,0,0,0,0}; // Last packet received from host (Der Host hat diese Packet gesandet) U8 In_Packet[8] = {0,0,0,0,0,0,0,0}; // Next packet to sent to host /*** [BEGIN] USB Descriptor Information [BEGIN] ***/.... ...... *** [ END ] USB Descriptor Information [ END ] ***/ //---------------------------------------------------------------------- ------- // Global VARIABLES //---------------------------------------------------------------------- ------- unsigned char SMB_DATA_IN[NUM_BYTES_RD]; unsigned char SMB_DATA_OUT[NUM_BYTES_WR]; unsigned char TARGET; // Target SMBus slave adress(T5300 address) bit SMB_BUSY; // Software flag to indicate when the // SMB_Read() or SMB_Write() functions // have claimed the SMBus bit SMB_RW; // Software flag to indicate the // direction of the current transfer unsigned long NUM_ERRORS; // Counter for the number of errors. // 16-bit SFR declarations //sfr16 TMR3RL = 0x92; // Timer3 reload registers //sfr16 TMR3 = 0x94; // Timer3 counter registers sbit SDA = P0^0; // SMBus on P0.0 sbit SCL = P0^1; // and P0.1 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!! //---------------------------------------------------------------------- ----------------- // Function Prototypes //---------------------------------------------------------------------- ----------------- //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!! // Function Prototypes SMB void SMBus_Init (void); void Timer1_Init (void); void Timer3_Init (void); void Port_Init_SMB (void); void SMBus_ISR (void); void Timer3_ISR (void); void Ext_Interrupt_Init (void); // Configure External Interrupts (/INT0 void INT0_ISR (void); void INT1_ISR (void) // and /INT1) void SMB_Write (void); void SMB_Read (void); void T0_Wait_ms (unsigned char ms); // Function Prototypes USB void Port_Init_USB(void); void Suspend_Device(void); void Initialize(void); //INTERRUPT(USB_API_TEST_ISR, INTERRUPT_USBXpress); //INTERRUPT_PROTO(USB_API_TEST_ISR, INTERRUPT_USBXpress); //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%% // Main Routine //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%% void main(void) { PCA0MD &= ~0x40; // Disable Watchdog timer OSCICN |= 0x03; // Set internal oscillator to highest // setting of 12MHz // If slave is holding SDA low because of an improper SMBus reset or error while(!SDA) { // Provide clock pulses to allow the slave to advance out // of its current state. This will allow it to release SDA. XBR1 = 0x40; // Enable Crossbar SCL = 0; // Drive the clock low for(i = 0; i < 255; i++); // Hold the clock low SCL = 1; // Release the clock while(!SCL); // Wait for open-drain // clock output to rise for(i = 0; i < 10; i++); // Hold the clock high XBR1 = 0x00; // Disable Crossbar } Port_Init_SMB (); // Initialize Crossbar and GPIO for SMBus Timer1_Init (); // Configure Timer1 for use as SMBus // clock source Timer3_Init(); // Configure Timer3 for use with SMBus // low timeout detect SMBus_Init (); // Configure and enable SMBus EIE1 |= 0x01; // Enable the SMBus interrupt //LED = 0; EA = 1; // Global interrupt enable //-----------------------Main Routine ---------------------------------------- USB_Clock_Start(); // Init USB clock before calling USB_Init USB_Init(USB_VID,USB_PID,USB_MfrStr,USB_ProductStr,USB_SerialStr,USB_Max Power,USB_PwAttributes,USB_bcdDevice); // initialize the USB IDs and configurations Initialize(); // Enables all peripherals needed for the // application: Crossbar GPIO, Timers, ...etc USB_Int_Enable(); // enables the USB API to generate interrupts on the following // API events (USB_Reset, USB BLOCK_WRITE completed,..) data_in = 0; while (1) { TARGET = SLAVE_ADDR; // Target the Slave (T5300) for next SMBus // transfer T0_Wait_ms(5); // wait 5 ms after the previous READ_DF until the next // READ_MR comes SMB_Read(); // I2C READ_MR (Measurement Request) T0_Wait_ms(12); // wait 12 ms for measurement and DSP Calculation // between READ_MR and a valid READ_DF //SMB_Read(); // I2C READ_DF (valid Data Fetch) // T0_Wait_ms (1); // Wait 1 ms for (data_in = 0; data_in < NUM_BYTES_RD; data_in++) { In_Packet[data_in]= SMB_DATA_IN[data_in] // write Data from SMBus to the In_Packet vector Array // This data array is to sent to host data_in++; } Block_Write(In_Packet, 5); // Write this 5 byte In_Packet buffer of data //to the host via the USB } }
Wenn Du Deinen Code in [ c ] und [ / c ] (jeweils ohne Leerzeichen) einschließt, wird er lesbarer. Der Fehler aber ist trotzdem leicht zu finden:
1 | void Ext_Interrupt_Init (void); // Configure External Interrupts (/INT0 |
2 | void INT0_ISR (void); |
3 | void INT1_ISR (void) // and /INT1) |
4 | |
5 | void SMB_Write (void); |
Na? Hinter dem Funktionsprototypen von INT1_ISR fehlt das Semikolon.
Nimm ein USB-Beispiel aus dem Silabs-Forum als Grundstock und bau dann den Rest drumherum: http://www.cygnal.org/ubb/Forum9/HTML/000945.html Gruß Ralf
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.