Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5843035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:05:53+00:00 2026-05-22T12:05:53+00:00

The function below reads an image a page at a time using read_page(pageIter, pageArr,

  • 0

The function below reads an image a page at a time using read_page(pageIter, pageArr, PAGESIZE) and outputs the data on the DOUT AND CCLK pins.

I was told it was inefficient but I can’t seem to find a way to make it faster. It is basically a pipe ,running on a 64 pin uProcessor, between two memory spaces. One holds the image and the other receives the image.

I’ve used the register keyword, removed array indexing and replaced with pointer arithemetic, but it needs to be faster.

Thanks!

/*
Port C Pin Out
*/
#define     BIT0        0x01    // CCLK
#define     BIT1        0x02    // CS_B
#define     BIT2        0x04    // INIT_B
#define     BIT3        0x08    // PROG_B
#define     BIT4        0x10    // RDRW_B
#define     BIT5        0x20    // BUSY_OUT
#define     BIT6        0x40    // DONE
#define     BIT7        0x80    // DOUT (DIN)

/*
PAGE
*/

#define     PAGESIZE    1024    // Example

void copyImage(ulong startAddress, ulong endAddress)
  {
  ulong pageIter;
  uchar *eByte, *byteIter, pageArr[PAGESIZE];
  register uchar bitIter, portCvar;
  portCvar = PORTC;
  /* Loops through pages in an image using ulong type*/
  for(pageIter = startAddress ;  pageIter <= endAddress ; pageIter += PAGESIZE)
    {
    read_page(pageIter, pageArr, PAGESIZE);
    eByte = pageArr+PAGESIZE;
    /* Loops through bytes in a page using pointer to uchar (pointer to a byte)*/
    for(byteIter = pageArr; byteIter <= eByte; byteIter++)
      {
      /* Loops through bits in byte and writes to PORTC - DIN ANC CCLK  */
      for(bitIter = 0x01; bitIter != 0x00; bitIter = bitIter << 1)
        {
        PORTC = portCvar | BIT0;
        (bitIter & *byteIter) ? (PORTC = portCvar & ~BIT7) : (PORTC = portCvar | BIT7);
        PORTC = portCvar & ~BIT0;
        }
      }
    }
  }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T12:05:54+00:00Added an answer on May 22, 2026 at 12:05 pm

    Probably you can go faster by unrolling the transmission of each byte with something like

    PORTC = clock_1; PORTC = (value & 0x01 ? data1 : data0); PORTC = clock_0;
    PORTC = clock_1; PORTC = (value & 0x02 ? data1 : data0); PORTC = clock_0;
    PORTC = clock_1; PORTC = (value & 0x04 ? data1 : data0); PORTC = clock_0;
    PORTC = clock_1; PORTC = (value & 0x08 ? data1 : data0); PORTC = clock_0;
    PORTC = clock_1; PORTC = (value & 0x10 ? data1 : data0); PORTC = clock_0;
    PORTC = clock_1; PORTC = (value & 0x20 ? data1 : data0); PORTC = clock_0;
    PORTC = clock_1; PORTC = (value & 0x40 ? data1 : data0); PORTC = clock_0;
    PORTC = clock_1; PORTC = (value & 0x80 ? data1 : data0); PORTC = clock_0;
    

    after precomputing once outside the image loop

    unsigned char clock_1 = portC | BIT0;
    unsigned char clock_0 = portC & ~BIT0;
    unsigned char data1 = portC | BIT7;
    unsigned char data0 = portC & ~BIT7;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The function below takes a python file handle, reads in packed binary data from
i am adding collection of radio buttons to my page using jQuery below $(document).ready(function()
I have an example function below that reads in a date as a string
I am using jquery datepicker, please see below code $(document).ready(function() { $(.txtDate).datepicker({ showOn: 'button',
The function below prints a color raster image to a PCL-5 printer. The function
I am using the function below inside a thread to receive the byte[] via
I have an image with an associated image map (below) and I'm using jQuery
Basically, on my page an image is called to div#imagebox when the function is
I have an HTML page. I have created a frame using background repeat function.
The function below is logging the 0, z and the 1 ok... but its

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.