Hallo,
ich habe noch ein Problem....
Ich habe ein Routine für den SPI Bus (Interruptgesteuert) geschrieben uns stehe vor dem Problem, dass ich einen Pointer eines Arrays, in das dieDaten aus dem SRAM geschrieben werden sollen, übergeben möchte.
Was mache ich falsch?
Hier die betreffenden Routinen:
SPI
und SRAMCode:void SPI_master_read (char **data_ptr, uint8_t data_bytes) { if (data_bytes > 0) { while (SPI_busy == 1); DataToRead = data_bytes; PtrToData = *data_ptr; SPI_dir = READ; SPDR = 0xff; SPI_busy = 1; } } ISR (SPI_STC_vect) { // Point to next Char in String switch (SPI_dir) { case WRITE: if (DataToSend != 0) // if end not reached { DataToSend--; PtrToData++; SPDR = *PtrToData; // send Character } else { if (SPI_hold == 0) { SPI_busy = 0; // if end reached enable transmission of next String Disable_SPI_Device; } else { SPI_busy = 0; SPI_hold--; } } break; case READ: if (DataToRead != 0) { DataToRead--; *PtrToData = SPDR; char glu[2]; glu[0] = *PtrToData; glu[1] = '\0'; PtrToData++; SPDR = 0xff; } else { *PtrToData = SPDR; SPI_busy = 0; Disable_SPI_Device; } break; } }
mit dem AufrufCode:void SRAM_read (uint16_t adress, char **sram_ptr, uint8_t sram_bytes) { char send [3]; //send read instruction and start adress send [0] = 0x03; send [1] = adress >> 8; send [2] = adress & 0xff; SPI_master_send (&send [0], 3, 1); SPI_master_read (sram_ptr, sram_bytes); }
Die Datenübertragung funktioniert (einzelne Bytes werden übertragen).Code:char tempbuf [13]; SRAM_read (0x0001, tempbuf, 12);
Vielen Dank!
MfG, Marten83







Zitieren

Lesezeichen