View previous topic :: View next topic |
Author |
Message |
pmuldoon
Joined: 26 Sep 2003 Posts: 218 Location: Northern Indiana
|
can't control pullups |
Posted: Thu Oct 13, 2011 7:14 am |
|
|
CCS ver 4.125
chip 16F505
The weak pullups default on and I can't turn them off.
the header file sez:
Quote: | // Discrete I/O Functions: SET_TRIS_x(), OUTPUT_x(), INPUT_x(),
// PORT_x_PULLUPS(), INPUT(),
// OUTPUT_LOW(), OUTPUT_HIGH(),
// OUTPUT_FLOAT(), OUTPUT_BIT() |
but the compiler doesn't recognize the port_b_pullups() function.
the header also sez:
Quote: | #define DISABLE_PULLUPS 0x40 // for 508 and 509 only |
I tried that even tho it is for the smaller chips (option reg is similar) but stil l no luck.
I finally forced it using #asm and it seems to be setup properly now.
Here's both - I've no clue what the compiler was trying to do.
Code: | setup_wdt(WDT_18MS | DISABLE_PULLUPS);
#asm
movlw 0x48
option
#endasm |
lists as this:
Code: | .................... setup_wdt(WDT_18MS | DISABLE_PULLUPS);
009A: CLRF 08
009B: CLRF 01
009C: MOVLW 0F
009D: OPTION
009E: CLRWDT
009F: MOVF 08,W
00A0: OPTION
.................... #asm
.................... movlw 0x48
00A1: MOVLW 48
.................... option
00A2: OPTION
.................... #endasm |
Am I just missing something here, or is it a compiler bug? Like many of you, I'm working on a project due yesterday... |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9225 Location: Greensville,Ontario
|
|
Posted: Thu Oct 13, 2011 9:24 am |
|
|
I downloaded the datasheet and in the 'summary of port registers' it says that both 'wakeup pullup' and 'pullup' are defaulted to OFF ( set high ).
With that in mind, I suspect the compiler's got a bug.
Also looked at the header file and like you the 508 values should work for the 505.
It's be interesting to see what the listing says is being set(or reset in this case). |
|
|
pmuldoon
Joined: 26 Sep 2003 Posts: 218 Location: Northern Indiana
|
|
Posted: Thu Oct 13, 2011 9:31 am |
|
|
Thanks, I thought I was just missing something.
I'll fwd to CCS tech support. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Thu Oct 13, 2011 9:45 am |
|
|
If you try with 3.249, You will see that though it does a bit of extra work, it does end up writing 0x48 to the option register, if 0x48 is given as the value to use:
Code: |
.................... setup_wdt(0x48);
0003: MOVLW 48
0004: MOVWF 08
0005: MOVLW 07
0006: CLRF 01
0007: MOVLW 0F
0008: OPTION
0009: CLRWDT
000A: MOVF 08,W
000B: OPTION
|
However, repeat with any of the V4 compilers, and it seems to screw this up, writing zero instead....
Definately a bug I'm afraid.
Best Wishes |
|
|
|