View previous topic :: View next topic |
Author |
Message |
giankaclimb
Joined: 23 Jun 2010 Posts: 5 Location: ITALY, Fermo
|
Problems to address registers and PortF PortG on PIC16F1947 |
Posted: Wed Jun 23, 2010 3:04 am |
|
|
[code assembler]
1093: set_tris_f(0x37);
06D4 3037 MOVLW 0x37
06D5 0021 MOVLB 0x1
06D6 0091 MOVWF 0x11
/* The error is in addressing the registers of PORTG as seen in the example:
where the TRISG register is in memory location 17 (11_hexadecimal) of BANK1 ... this is a abnormal error ------->>>> but must be (as specified by Microchip) in memory location 13 (D_hexadecimal) of Bank6 */
1094: output_bit(PIN_G3,1);
06D7 0022 MOVLB 0x2
06D8 1592 BSF 0x12, 0x3
06D9 0021 MOVLB 0x1
06DA 1192 BCF 0x12, 0x3
/* The error is in addressing the registers of PORTG as seen in the example:
where the LATG register is in memory location 17 (11_hexadecimal) of BANK2 ... this is a abnormal error ------->>>> but must be (as specified by Microchip) in memory location 13 (D_hexadecimal) of Bank7 */
HELP ME!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
|
giankaclimb
Joined: 23 Jun 2010 Posts: 5 Location: ITALY, Fermo
|
Re: Problems to address registers and PortF PortG on PIC16F1 |
Posted: Wed Jun 23, 2010 3:05 am |
|
|
giankaclimb wrote: | [code assembler]
1093: set_tris_f(0x37);
06D4 3037 MOVLW 0x37
06D5 0021 MOVLB 0x1
06D6 0091 MOVWF 0x11
/* The error is in addressing the registers of PORTG as seen in the example:
where the TRISG register is in memory location 17 (11_hexadecimal) of BANK1 ... this is a abnormal error ------->>>> but must be (as specified by Microchip) in memory location 13 (D_hexadecimal) of Bank6 */
1094: output_bit(PIN_G3,1);
06D7 0022 MOVLB 0x2
06D8 1592 BSF 0x12, 0x3
06D9 0021 MOVLB 0x1
06DA 1192 BCF 0x12, 0x3
/* The error is in addressing the registers of PORTG as seen in the example:
where the LATG register is in memory location 17 (11_hexadecimal) of BANK2 ... this is a abnormal error ------->>>> but must be (as specified by Microchip) in memory location 13 (D_hexadecimal) of Bank7 */
HELP ME!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Wed Jun 23, 2010 3:11 am |
|
|
What is your compiler version number? |
|
|
giankaclimb
Joined: 23 Jun 2010 Posts: 5 Location: ITALY, Fermo
|
|
Posted: Wed Jun 23, 2010 3:16 am |
|
|
ckielstra wrote: | What is your compiler version number? |
4.109 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jun 23, 2010 2:31 pm |
|
|
Vs. 4.109 is buggy for the 16F1947 on Ports F and G. They're using
the wrong register addresses in the compiler database. Also, the .H file
has the wrong pin constants for those ports.
I've posted a program below with some work-around routines.
Here's the .LST file output. It looks correct:
Code: |
.................... output_bit(PIN_G3, 1);
0018: MOVLB 06
0019: BCF 0D.3
001A: MOVLB 05
001B: BSF 0D.3
....................
.................... set_TRISF(0x37);
001C: MOVLW 37
001D: MOVLB 06
001E: MOVWF 0C
....................
|
Code: |
#include <16F1947.h>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#locate TRISF = 0x30C
#locate TRISG = 0x30D
#define set_TRISF(x) TRISF = x
#define set_TRISG(x) TRISG = x
#define PIN_F0 5216
#define PIN_F1 5217
#define PIN_F2 5218
#define PIN_F3 5219
#define PIN_F4 5220
#define PIN_F5 5221
#define PIN_F6 5222
#define PIN_F7 5223
#define PIN_G0 5224
#define PIN_G1 5225
#define PIN_G2 5226
#define PIN_G3 5227
#define PIN_G4 5228
#define PIN_G5 5229
// This macro is a substitute for the CCS output_bit() function.
// It replaces the built-in function. First it sets the TRIS to
// output for the selected pin. Then it sets or clears the Port
// pin, based on the 2nd parameter being 1 or 0.
#define output_bit(pin, value) { \
bit_clear(*(int8 *)((pin >> 3) + 0x80), pin & 7); \
if(value) \
bit_set(*(int8 *)(pin >> 3), pin & 7); \
else \
bit_clear(*(int8 *)(pin >> 3), pin & 7); \
}
//===============================
void main()
{
output_bit(PIN_G3, 1);
set_TRISF(0x37);
while(1);
}
|
|
|
|
giankaclimb
Joined: 23 Jun 2010 Posts: 5 Location: ITALY, Fermo
|
|
Posted: Thu Jun 24, 2010 4:25 am |
|
|
Many thanks |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Thu Jun 24, 2010 5:20 am |
|
|
Did someone report this to CCS so they can fix it? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jun 24, 2010 1:34 pm |
|
|
I reported it just now.
------------
Edited to add an update:
I got an email from CCS support. They say it will be fixed in
the next version, presumably 4.110.
--------------------------
Edited to add:
You requested a substitute for the input() function in a PM.
Here's the macro that I created:
Code: |
#define input(pin) \
((bit_set(*(int8 *)((pin >> 3) + 0x80), pin & 7) & 0) | \
(bit_test(*(int8 *)(pin >> 3), pin & 7)))
|
Last edited by PCM programmer on Fri Jul 02, 2010 12:55 pm; edited 2 times in total |
|
|
giankaclimb
Joined: 23 Jun 2010 Posts: 5 Location: ITALY, Fermo
|
|
Posted: Fri Jun 25, 2010 12:45 am |
|
|
PCM programmer wrote: | I reported it just now. |
I had already done three days ago, had better tell him more.
Thanks for the Macro to output_bit, I would appreciate if you could pass the Macro for the two input_bit PORT indicated.
|
|
|
|