electronics forum

Rules | Recent posts | topic RSS | Search | Register  | Log in

serial clock GPIO


Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers -> serial clock GPIO
Author Message
vjcro



Joined: 14 Mar 2009
Posts: 2


Post28 Jun 2009 9:56   

communicate gpio to serial device


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.
Back to top
Google
AdSense
Google Adsense




Post28 Jun 2009 9:56   

Ads




Back to top
doraemon



Joined: 21 Jun 2009
Posts: 141
Helped: 17
Location: Japan


Post28 Jun 2009 12:53   

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 wrote:
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.
Back to top
Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers -> serial clock GPIO
Page 1 of 1 All times are GMT + 1 Hour
Similar topics:
How to implement a RS-232 serial interface using GPIO? (6)
ARM7 which is differences between fast GPIO and low GPIO (5)
Clock and data recovery for serial Link (4)
Using a 74HC595 serial/parallel register with a single clock (4)
I2c to GPIO (2)
gpio as uart. (3)
Help PLZ!! FPGA Clock- creating a clock from the input clock (4)
I2C implemented by GPIO (5)
TMS320C6455 GPIO Configure (2)
TUSB firmware GPIO setting (1)


Abuse || Administrator || Moderators || Support us || sitemap
topic RSS