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

Help w/ #bit please SOLVED

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



Joined: 26 Nov 2007
Posts: 16

View user's profile Send private message

Help w/ #bit please SOLVED
PostPosted: Tue Sep 16, 2008 2:17 pm     Reply with quote

Using PCH4.078 PIC18F4423

declared in header:
Code:

#bit CKE  = 0xFC7.6
#define TRUE 1


in app:
Code:

CKE = TRUE;


While the above compiles fine, it doesnt execute correctly in circuit. This dosnt work as well:
Code:

CKE = 1;


The only way I can get it to execute correctly is to set CKE as follows:

Code:

output_high(CKE)


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

View user's profile Send private message

PostPosted: Tue Sep 16, 2008 2:37 pm     Reply with quote

Quote:
output_high(CKE)

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

View user's profile Send private message

PostPosted: Tue Sep 16, 2008 2:45 pm     Reply with quote

PCM programmer wrote:
Quote:
output_high(CKE)

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







PostPosted: Wed Sep 17, 2008 2:46 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Sep 17, 2008 8:55 am     Reply with quote

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
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