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

PIC18F46K22 Compiler Problem?

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



Joined: 09 Oct 2008
Posts: 15

View user's profile Send private message

PIC18F46K22 Compiler Problem?
PostPosted: Wed Dec 21, 2011 10:06 am     Reply with quote

I've been trying to use the Weak Pull-up feature of Port B, I got erroneous results. Examining the ASM output showed the compiler using the wrong register value for the port_b_pullups() call.


Also GETENV("SFR:TXSTA1") gives 0. Have I got the name wrong or is this (and maybe its ilk) missing?

Compiler version 4.127
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Dec 21, 2011 2:27 pm     Reply with quote

Quote:

Examining the ASM output showed the compiler using the wrong register
value for the port_b_pullups() call.

Put the following 4 lines above main(). This macro (with the #define
statement) will replace the buggy built-in port_b_pullups() function:
Code:

#byte WPUB = 0xF61
#byte INTCON2 = 0xFF1
#bit RBPU = INTCON2.7
#define port_b_pullups(x)  WPUB = x;  x ? (RBPU = 0) : (RBPU = 1);



Quote:
Also GETENV("SFR:TXSTA1") gives 0.

I didn't get that. If I compile the program shown below with vs. 4.127
and look at the .LST file, I see this:

Quote:
....................
.................... result = TXSTA1;
00032: MOVFF FAC,05

0xFAC is the correct register address of TXSTA1 in the 18F46K22.
This was tested with vs. 4.127.
Code:

#include <18F46K22.h>
#fuses INTRC_IO, NOWDT, BROWNOUT, PUT, NOPBADEN
#use delay(clock=4M)

#byte TXSTA1 = getenv("SFR:TXSTA1")
//=========================================
void main()

int8 result;

result = TXSTA1;

while(1);
}
 
Ttelmah



Joined: 11 Mar 2010
Posts: 19267

View user's profile Send private message

PostPosted: Wed Dec 21, 2011 4:08 pm     Reply with quote

Though the posted version of GETENV should work, there have been problems reported with the latest compilers, being 'strict' about the presence of spaces or tabs. So if you use a tab between the '=' and the GETENV, problems have been seen, and if extra spaces are added some problems also seem to occur. Type it exactly as PCM_programmer has it, and it does work.

Best Wishes
picnic



Joined: 09 Oct 2008
Posts: 15

View user's profile Send private message

PostPosted: Thu Dec 22, 2011 2:53 am     Reply with quote

Thanks for the help guys Smile
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