Atmel C one clock cycle

Hi,

I'm a bit struck at present as I am trying to make my data transfer over a clock cycle. I'm new to C in terms of using it on microcontrollers. my task is like -

__ __ __ __ __ __| |__| |__| |__| |__| |____ - clock ____ ____ ____ __| |___| |___| |_______- data

I am using a AT89C51ED2, I don't understand how to use the timers, and to achieve my goal I dont get whether I need to watch the overflow of both TH0 and TH1.

Can anyone show me an example because im very confused by this...

I don't really understand the setup of them and the values that are placed into the things like TMOD, SCON, TH1, TL1...

Thank you for your response

David

Reply to
googlinggoogler
Loading thread data ...

I would use an already implemented, tested and wide ranging bus such as I2C. Phillips has an extensive bank of information and a number of ready built modules, LCD panels etc have it built in. See:

formatting link

Goto

formatting link
from the wealth of knowledge about your chip there is a link about half way down there is a link on the right hand side for I2C drivers for uVision which I'm guessing is a compiler/debugging platform.

I hope this helps.

Reply to
Brendan Gillatt

Sorry Brendan but you dont understand, a device called a PLL300 requires that data be fed into it via this means, im not great at C hence my reason for asking and i've never used an Atmel before so im kinda, ermmm, drowning at the moment.

It should be be a simple problem and being well versed in VHDL have no problems in that (if(clk'event and clk = '1')), but there is no simple means to monitor an event that i know in C, although.

My first thoughts is to cascade 3 "if" statements -

if(x=1) if(x=0) if(x=0)

But this seems very clumsey to me. And would like to try and use the timers although dont really know how :-)

David

Reply to
googlinggoogler

Whoooppps, should be-

if(x=1) if(x=0) if(x=1)

David

Reply to
googlinggoogler

Please use a non-proportional font when drawing timing diagrams. I can not see how the signals relate to each other. Also, I would need to know at what speeds you are planning to send the signal (bit banging), and if you are planning to do other tasks at the same time (interrupt controlled w/timer). Lastly, it would be useful to know if you are generating the clock with the Atmel, or if is generated elsewhere.

Buuuuut....

better would be to check example code on the many Atmel fan sites out there

best would be to post this in 'comp.arch.embedded' :-)

Matthias

Reply to
Matthias Melcher

Hi, I couldnt figure out the font thing after testing, so i've placed the image on a webpage -

formatting link
I want to use the atmel for the clock, and its not really fussy regarding time as the device only requires that the data be transfered in this means with a clock cycle of greater than 25ns.

thanks

David

Reply to
googlinggoogler

Hi, Just realised that my ascii image might be muddled up, so i've placed the image on a webpage -

formatting link
I want to use the atmel for the clock, and its not really fussy regarding time as the device only requires that the data be transfered in this means with a clock cycle of greater than 25ns.

thanks

David

Reply to
googlinggoogler

This is much like SPI. Search for code which bit-bangs SPI, or if you have SPI support, use it. You're right it's an easy problem and there must be a ton of code out there.

We bit bang SPI on our TStik, using 8051 assy code, you are welcome to consider it:

formatting link

Reply to
bboyes

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.