View previous topic :: View next topic |
Author |
Message |
picnic
Joined: 09 Oct 2008 Posts: 15
|
PIC18F46K22 Compiler Problem? |
Posted: Wed Dec 21, 2011 10:06 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Dec 21, 2011 2:27 pm |
|
|
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);
}
|
|
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19360
|
|
Posted: Wed Dec 21, 2011 4:08 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
picnic
Joined: 09 Oct 2008 Posts: 15
|
|
Posted: Thu Dec 22, 2011 2:53 am |
|
|
Thanks for the help guys ![Smile](images/smiles/icon_smile.gif) |
|
![](templates/subSilver/images/spacer.gif) |
|