|
|
View previous topic :: View next topic |
Author |
Message |
epalite
Joined: 06 Apr 2008 Posts: 16
|
Extra binary line generated from CCS PCM |
Posted: Tue Apr 07, 2009 10:17 pm |
|
|
Hi,
Following line was extracted, didn't quite understand why was line 387 generated. Any good reason PCM has to dump W into 0x4f? Thanks!
PCM version info:
CCS PCM C Compiler, Version 4.073, 38894
Code: | 219: set_tris_a(TRISA | 0x20);
385 0805 MOVF 0x5, W
386 3820 IORLW 0x20
387 00CF MOVWF 0x4f
388 0085 MOVWF 0x5 |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Apr 07, 2009 10:32 pm |
|
|
Tell us what PIC you're using. Post a little test program that contains
only that line in main(), and that compiles without errors if it's pasted
into MPLAB. |
|
|
epalite
Joined: 06 Apr 2008 Posts: 16
|
|
Posted: Wed Apr 08, 2009 1:04 am |
|
|
Here you go, the source,
Code: |
#include <16F690.h>
#define PORTA_MASK 0x01
#byte TRISA = 0x85
void main() {
set_tris_a(TRISA | PORTA_MASK);
}
|
and the compiled, it now appears at line 0x01e (MOVWF 0x26),
Code: |
1: #include <16F690.h>
000 3000 MOVLW 0
001 008A MOVWF 0xa
002 2804 GOTO 0x4
003 0000 NOP
2:
3: #define PORTA_MASK 0x01
4:
5: #byte TRISA = 0x85
6:
7: void main() {
004 0184 CLRF 0x4
005 1383 BCF 0x3, 0x7
006 301F MOVLW 0x1f
007 0583 ANDWF 0x3, F
008 1703 BSF 0x3, 0x6
009 101F BCF 0x1f, 0
00A 109F BCF 0x1f, 0x1
00B 111F BCF 0x1f, 0x2
00C 119F BCF 0x1f, 0x3
00D 1303 BCF 0x3, 0x6
00E 131F BCF 0x1f, 0x6
00F 3000 MOVLW 0
010 1703 BSF 0x3, 0x6
011 009E MOVWF 0x1e
012 0199 CLRF 0x19
013 019A CLRF 0x1a
014 1683 BSF 0x3, 0x5
015 019E CLRF 0x1e
016 1283 BCF 0x3, 0x5
017 019B CLRF 0x1b
018 1303 BCF 0x3, 0x6
019 128D BCF 0xd, 0x5
8: set_tris_a(TRISA | PORTA_MASK);
01A 1683 BSF 0x3, 0x5
01B 0805 MOVF 0x5, W
01C 3801 IORLW 0x1
01D 1283 BCF 0x3, 0x5
01E 00A6 MOVWF 0x26
01F 1683 BSF 0x3, 0x5
020 0085 MOVWF 0x5
021 0063 SLEEP
|
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Apr 08, 2009 10:26 am |
|
|
Quote: | #define PORTA_MASK 0x01
#byte TRISA = 0x85
set_tris_a(TRISA | PORTA_MASK); |
You're using the set_tris_a() function incorrectly. This function only
takes a bitmask as the parameter. You don't give it the address of
the TRISA register. The set_tris_a() function is designed to operate
on the TRISA register. The compiler knows the address of that register
inherently.
Just do this and you'll get correct ASM code:
Code: | set_tris_a(PORTA_MASK); |
|
|
|
epalite
Joined: 06 Apr 2008 Posts: 16
|
|
Posted: Wed Apr 08, 2009 7:34 pm |
|
|
PCM programmer wrote: |
Just do this and you'll get correct ASM code:
Code: | set_tris_a(PORTA_MASK); |
|
My intent was to set only specific bit but not others. I found the work arounds, and list the result of various methods:
Code: |
9: set_tris_a(TRISA | PORTA_MASK);
01A 1683 BSF 0x3, 0x5
01B 0805 MOVF 0x5, W
01C 3801 IORLW 0x1
01D 1283 BCF 0x3, 0x5
01E 00A6 MOVWF 0x26
01F 1683 BSF 0x3, 0x5
020 0085 MOVWF 0x5
10: set_tris_a(PORTA_MASK);
021 3001 MOVLW 0x1
022 0085 MOVWF 0x5
11: TRISA |= PORTA_MASK;
023 1405 BSF 0x5, 0
|
|
|
|
|
|
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
|