View previous topic :: View next topic |
Author |
Message |
bignick270
Joined: 11 Sep 2008 Posts: 44
|
problem with initial state of input pin |
Posted: Fri Oct 17, 2008 7:00 am |
|
|
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
|
|
Posted: Fri Oct 17, 2008 7:41 am |
|
|
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
|
|
Posted: Fri Oct 17, 2008 7:43 am |
|
|
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
|
|
Posted: Fri Oct 17, 2008 7:47 am |
|
|
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
|
|
Posted: Fri Oct 17, 2008 3:10 pm |
|
|
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
|
|
Posted: Mon Oct 20, 2008 6:48 am |
|
|
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. |
|
|
|