Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void readHiRomBanks( unsigned int start, unsigned int total, SdFile *file)
- {
- byte buffer[1024];
- delay(1000); // let previous message show before starting
- display_Clear();
- unsigned long startTimeBank = millis();
- unsigned long startTimeAllBanks = millis();
- uint16_t c = 0;
- uint16_t currByte = 0;
- for (int currBank = start; currBank < total; currBank++) {
- startTimeBank = millis();
- PORTL = currBank;
- currByte = 0;
- while (1) {
- c = 0;
- while (c < 1024) {
- PORTF = (currByte & 0xFF);
- PORTK = ((currByte >> 8) & 0xFF);
- // Wait for the Byte to appear on the data bus
- // Arduino running at 16Mhz -> one nop = 62.5ns
- // slowRom is <= 200ns, fastRom is <= 120ns, S-CPU max read speed: 3.57MHz / 280ns
- __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t"); // using 5 x 62.5 = 312.5ns
- buffer[c] = PINC;
- c++;
- currByte++;
- }
- file->write(buffer, 1024);
- // exit while(1) loop once the uint16_t currByte overflows to 0 > this bank is done
- if (currByte == 0) break;
- }
- println_Msg(millis() - startTimeBank);
- display_Update();
- if (currBank % 8 == 0) display_Clear();
- }
- display_Clear();
- print_Msg(F("Time spent: "));
- println_Msg(millis() - startTimeAllBanks);
- display_Update();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement