CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

source code for timing diagram

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Atma



Joined: 08 Aug 2005
Posts: 22

View user's profile Send private message

source code for timing diagram
PostPosted: Wed Sep 07, 2005 4:44 am     Reply with quote

hi there

I am trying to write a program for the timing diagram figure 6.1 in manual 39025f.pdf related to the PIC16F873 in C but have no idea how to go about doing that. Can some one tell me how to write the source code? thanks

All help will be appreciated.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Sep 08, 2005 1:20 pm     Reply with quote

Code:
I am trying to write a program for the timing diagram figure 6.1 in manual 39025f.pdf related to the PIC16F873 in C but have no idea how to go about doing that. Can some one tell me how to write the source code ?

You can use software SPI to make the signals.
http://www.ccsinfo.com/forum/viewtopic.php?t=23791&highlight=software+spi

Also read how other people make PIC programmers:
http://www.piclist.com/techref/microchip/devprogs.htm
newguy



Joined: 24 Jun 2004
Posts: 1909

View user's profile Send private message

PostPosted: Thu Sep 08, 2005 1:37 pm     Reply with quote

Take a careful look at the timing diagram, then write code to do what's in it.

For example, both the data & clock lines must be low before MCLR is set high. They must also be low for at least 100 ns before MCLR is raised (tset0 from Table 6-1).

This would be coded something like:

Code:
output_low(CLOCK_PIN);
output_low(DATA_PIN);
delay_us(1); // only have to delay for 100 ns, but this will make sure the delay is enough
output_high(MCLR_PIN);


You'll have to define CLOCK_PIN etc to correspond to individual pins on the programming PIC.

From the diagram, once the above instructions have executed, everything then must "hold" for thold0. From Table 6-1, thold0 is at least 5 us.

Now you'd add the following line to account for this delay:

Code:
delay_us(7); // 7 is "at least" 5, plus some padding, just in case


And so on, and so on, and so on.
Atma



Joined: 08 Aug 2005
Posts: 22

View user's profile Send private message

PostPosted: Mon Sep 12, 2005 8:16 am     Reply with quote

newguy wrote:
Take a careful look at the timing diagram, then write code to do what's in it.

For example, both the data & clock lines must be low before MCLR is set high. They must also be low for at least 100 ns before MCLR is raised (tset0 from Table 6-1).

This would be coded something like:

Code:
output_low(CLOCK_PIN);
output_low(DATA_PIN);
delay_us(1); // only have to delay for 100 ns, but this will make sure the delay is enough
output_high(MCLR_PIN);


You'll have to define CLOCK_PIN etc to correspond to individual pins on the programming PIC.

From the diagram, once the above instructions have executed, everything then must "hold" for thold0. From Table 6-1, thold0 is at least 5 us.

Now you'd add the following line to account for this delay:

Code:
delay_us(7); // 7 is "at least" 5, plus some padding, just in case


And so on, and so on, and so on.



hi there

thanks for the answer.
I have done that. Where i am confused is where i have to send a 14 bit data word when the clock cycle completes 16 cycles. How do i go about doing that ?

thanks
newguy



Joined: 24 Jun 2004
Posts: 1909

View user's profile Send private message

PostPosted: Mon Sep 12, 2005 11:04 am     Reply with quote

Someone else will have to help you here. The two extra bits are a start bit tacked onto the beginning and a stop bit tacked onto the end. The documentation does describe them. What's not clear, from my (quick) perusal of the documentation and the timing diagram, is what the start & stop bits should be - high or low.

The timing diagram seems to indicate that the start & stop bits may be high or low. Perhaps it doesn't matter? Try it with them high, low, or some combination to see if it works or not.
Guest








PostPosted: Mon Sep 12, 2005 11:07 am     Reply with quote

newguy wrote:
Someone else will have to help you here. The two extra bits are a start bit tacked onto the beginning and a stop bit tacked onto the end. The documentation does describe them. What's not clear, from my (quick) perusal of the documentation and the timing diagram, is what the start & stop bits should be - high or low.

The timing diagram seems to indicate that the start & stop bits may be high or low. Perhaps it doesn't matter? Try it with them high, low, or some combination to see if it works or not.


but then how do i code it in c? thats where i am confused. whats the code i would use in c to append the start and stop bis and the rest of the data word?

thanks
MikeValencia



Joined: 04 Aug 2004
Posts: 238
Location: Chicago

View user's profile Send private message Send e-mail Yahoo Messenger

PostPosted: Mon Sep 12, 2005 11:44 am     Reply with quote

Anonymous wrote:
newguy wrote:
Someone else will have to help you here. The two extra bits are a start bit tacked onto the beginning and a stop bit tacked onto the end. The documentation does describe them. What's not clear, from my (quick) perusal of the documentation and the timing diagram, is what the start & stop bits should be - high or low.

The timing diagram seems to indicate that the start & stop bits may be high or low. Perhaps it doesn't matter? Try it with them high, low, or some combination to see if it works or not.


but then how do i code it in c? thats where i am confused. whats the code i would use in c to append the start and stop bis and the rest of the data word?

thanks


You'll need a combination of delay_us() calls, output_high(), output_low(), etc.

Do you know how to program in C Question
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group