Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

What's the serial clock rate on a GPIO?

Status
Not open for further replies.

vjcro

Newbie level 2
Joined
Mar 14, 2009
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,301
Hello,

I'm quite new in programming microcontrollers.
I was wondering, if I want to make a 'clock' on a GPIO, what would be it's maximum rate? I suppose - if I put, for example: RB1=1, then RB1=0 in a loop, the clock rate will be twice the time of the execution time of the used instruction. Am I right?

The thing I would like to do is to accomplish my own simple serial communication with a FPGA. The uC would generate the serial clock on a pin and the FPGA would send the bits on a data pin.
One more question regarding this: is there a boundary regarding the serial clock rate in that kind of communication?

I would appreciate any help!
Thank you in advance.
 

serial clock rate

Hello!

Basically what you want to do is bit banging.
In this case, you may consider to have a standard transmission like
SPI. If you send a clock to your fpga and get one bit per clock, then
it is exactly what SPI does. But it will take you quite a few steps for each
bit.

If you transmit a byte like this (in pseudo code):
This supposes that one bit comes on rising edge of the clock.

Code:
const char BIT[] = {
    0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01
}

uint8 receive_byte(void) {
    uint8 i;
    uint8 retval = 0;
    for(i = 0 ; i < 8 ; ++i) {
        set_clock_bit_low();
        set_clock_bit_high();
        get_data_bit();
        if(data_bit) ret_val |= BIT[i];
    }
    return retval;
}

So as you see, it will take more than twice the instructions to set and reset
the port to get some usable data.

Dora.

vjcro said:
Hello,

I'm quite new in programming microcontrollers.
I was wondering, if I want to make a 'clock' on a GPIO, what would be it's maximum rate? I suppose - if I put, for example: RB1=1, then RB1=0 in a loop, the clock rate will be twice the time of the execution time of the used instruction. Am I right?

The thing I would like to do is to accomplish my own simple serial communication with a FPGA. The uC would generate the serial clock on a pin and the FPGA would send the bits on a data pin.
One more question regarding this: is there a boundary regarding the serial clock rate in that kind of communication?

I would appreciate any help!
Thank you in advance.
 

    vjcro

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top