Atmel C one cycle

Apr 04, 2006 3 Replies

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



the diagram is garbled, try again with a fixed-pitch font (eg courier).

Bye. Jasen

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

I see this _ _ _ _ | |_| |_| |_| |_ clk ___ ___ | |___| |___ data

you will too if you paste it into notepad etc...

and 'im guessing both are outputs, and possibly that data could have other patterns.

try this:

int a=databyte; /* databyte is 0x55 in the example waveform */ int n=8; int keep=(inportb(PORTNUMBER)&1)|2; do { int bits=(a&1)|keep; outportb(PORTNUMBER,bits); a=a>>1; bits&=~2; outportb(PORTNUMBER,bits); } while(--n); that'll send the data out bit 0 and the clock out bit 1 of port whose output is addresed by PORTNUMBER.LSB first, as fast as it can, which means if your clock is less than about 100Mhz it should work for you...

you'll probably need to modify parts of this to get it to work with the c compiler you have...

Bye. Jasen

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required