View previous topic :: View next topic |
Author |
Message |
wayneosdias
Joined: 26 Nov 2007 Posts: 16
|
Help w/ #bit please SOLVED |
Posted: Tue Sep 16, 2008 2:17 pm |
|
|
Using PCH4.078 PIC18F4423
declared in header:
Code: |
#bit CKE = 0xFC7.6
#define TRUE 1
|
in app:
While the above compiles fine, it doesnt execute correctly in circuit. This dosnt work as well:
The only way I can get it to execute correctly is to set CKE as follows:
What is interesting is that the 2 uppermost blocks of code compile and execute correctly on the 18F2523, the 28pin version of the 18F4423. What am I doing wrong?
Last edited by wayneosdias on Wed Sep 17, 2008 8:56 am; edited 1 time in total |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Sep 16, 2008 2:37 pm |
|
|
This will never work. The output_high() function expects a parameter in
the CCS pin number format.
I suspect that you really mean the output_bit() function. But that function
takes two parameters.
You need to post a real test program, and don't "type in" code into your
post. Copy and paste a short, compilable test program into a post. |
|
|
wayneosdias
Joined: 26 Nov 2007 Posts: 16
|
|
Posted: Tue Sep 16, 2008 2:45 pm |
|
|
PCM programmer wrote: |
This will never work. The output_high() function expects a parameter in
the CCS pin number format.
I suspect that you really mean the output_bit() function. But that function
takes two parameters.
You need to post a real test program, and don't "type in" code into your
post. Copy and paste a short, compilable test program into a post. |
Interestingly it does work as I posted. I contemplated the output_bit Fx, but I thought I needed the first parameter to be a byte and then just index the bit.
What exactly should my small program demonstrate? I am in the middle porting a significantly large (working)program.
Pardon my ignorance. |
|
|
Ttelmah Guest
|
|
Posted: Wed Sep 17, 2008 2:46 am |
|
|
Both the CKE=1, and CKE=TRUE statements correctly set the bit you want. Simply look at the assembler...
Using 'output_high', is definitely wrong, and liable to be doing things you don't expect. In fact the code generated for this, is remarkably complex. It starts by setting the CKE bit, then updates registers FE8, FE9, FEA, and FEF. It actually ends up turning off the CKE bit before it exits. It by default, is designed to update the associated 'TRIS' register, and becaue the value you are giving it is wrong, this goes completely 'screwy', and results in a whole lot of registers being changed...
If this works, it says two things:
1) Luck....
2) You don't actually want CKE turned on...
Best Wishes |
|
|
wayneosdias
Joined: 26 Nov 2007 Posts: 16
|
|
Posted: Wed Sep 17, 2008 8:55 am |
|
|
Ttelmah wrote: |
2) You don't actually want CKE turned on...
|
Yes you are correct, I had an #IFDEF setting CKE to a diff value for a diff app w/o a closing #ENDIF, so the output_high was actually killing it allowing the spi to work as intended.
The code I'm working with has a lot of redundancy, continually resetting already set bits. Going through and commenting them out also resolved the problem.
Thanks |
|
|
|