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 support@ccsinfo.com

problem with initial state of input pin

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



Joined: 11 Sep 2008
Posts: 44

View user's profile Send private message

problem with initial state of input pin
PostPosted: Fri Oct 17, 2008 7:00 am     Reply with quote

I am having a slight problem, I am pretty much doing a bit banged version of SPI and my data in is high when the program starts (seen it on a logic analyzer). The data in pin is pin D6.

The thing is I am rewriting the code in C from a previous version done in assembly and when it is loaded to the PIC16F877A the logic analyzer shows that it starts high and then it is dropped to a low state right after the program begins to run.

TRIS functions are set right when used with fast_io and I have also tried it without the fast_io.

Any ideas what could be doing this, could it be the compiler?

I have uploaded a small pdf with the two waveforms from the logic analyzer to an online file hosting services if you do not understand my description, sometimes pictures are better than words.
Also I am running version 4.0.74 of CCS

http://www.savefile.com/files/1844063
bignick270



Joined: 11 Sep 2008
Posts: 44

View user's profile Send private message

PostPosted: Fri Oct 17, 2008 7:41 am     Reply with quote

first off sorry to previous people who have looked at the message, i had the tags set incorrectly for the link and it is now fixed.

Other than that I have noticed that the data line goes high between rx of data with my code where it goes low in the assembly.

I tried to set it low like an output and then change the tris while using fast_io to make it an input and that worked somewhat at the beginning but not between rx of data.
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Fri Oct 17, 2008 7:43 am     Reply with quote

Are you saying you think the PIC is pulling the line low, even though it should be an input? Are there any pull-up or pull-down resistors? Many logic analyzer probes are only 100k input impedance and may be a pull-down in themselves. What else is on the line besides the PIC and the analyzer?
_________________
The search for better is endless. Instead simply find very good and get the job done.
bignick270



Joined: 11 Sep 2008
Posts: 44

View user's profile Send private message

PostPosted: Fri Oct 17, 2008 7:47 am     Reply with quote

there is a 240ohm resistor and that is it. The hardware/logic analyzer does not change between the assembly file and the c file.

So basically with the c code using CCS the line is pulled high when inactive and with the assembly code the line is pulled low when inactive and there is no hardware difference and the logic analyzer does not move.
Ttelmah
Guest







PostPosted: Fri Oct 17, 2008 3:10 pm     Reply with quote

Have you got the line:

setup_psp(PSP_DISABLED);

Otherwise the PSP hardware may affect this pin.

Best Wishes
bignick270



Joined: 11 Sep 2008
Posts: 44

View user's profile Send private message

PostPosted: Mon Oct 20, 2008 6:48 am     Reply with quote

The weird thing is that I had more success commenting out the setup_psp(PSP_DISABLED); which i had initially in my code.

Also I added inline assembly to change the tris. The fast_io and set tris would not work correctly for me but in the end i got it all worked out.
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