View previous topic :: View next topic |
Author |
Message |
JED
Joined: 13 Jul 2006 Posts: 8
|
18f4550 port D weak pullups. |
Posted: Tue Jan 30, 2007 9:39 am |
|
|
In the data sheet for the 18f4550 it states there is a port D weak pull up option enabled with bit 7 of �port E register� 0xF84 (found on p66, p120 and p123 of the data sheet) which contains port E i/o and some other configuration bits. I try to set this bit but it doesn�t seem to happen. When I read the value of RDPU in my program it is always 0. My compiler is PCWH v3.249. Any help would be greatly appreciated.
Best regards.
Code: | #include <18f4550.h>
#DEVICE ICD=TRUE
#FUSES NOWDT
#FUSES NOLVP
#FUSES HS
#use delay(clock=10000000)
#BIT RDPU=0xF84.7 //define port d pullup enable bit
void main()
{
RDPU=1; //turn on port d pullups
delay_ms(1);
} |
Code: | CCS PCH C Compiler, Version 3.249, 33321 29-Jan-07 23:03
Filename: C:\Program Files\PICC\myStuff\TestPullupE.lst
ROM used: 78 bytes (0%)
Largest free fragment is 31858
RAM used: 5 (0%) at main() level
6 (0%) worst case
Stack: 1 locations
*
0000: GOTO 0030
.................... #include <18f4550.h>
.................... //////// Standard Header file for the PIC18F4550 device ////////////////
.................... #device PIC18F4550
.................... #list
....................
.................... #device adc=8
.................... #DEVICE ICD=TRUE
.................... #FUSES NOWDT
.................... #FUSES NOLVP
....................
.................... #FUSES HS//PLL
.................... #use delay(clock=10000000)
0004: CLRF FEA
0006: MOVLW 06
0008: MOVWF FE9
000A: MOVF FEF,W
000C: BZ 002C
000E: MOVLW 03
0010: MOVWF 01
0012: CLRF 00
0014: DECFSZ 00,F
0016: BRA 0014
0018: DECFSZ 01,F
001A: BRA 0012
001C: MOVLW 3C
001E: MOVWF 00
0020: DECFSZ 00,F
0022: BRA 0020
0024: NOP
0026: NOP
0028: DECFSZ FEF,F
002A: BRA 000E
002C: GOTO 004C (RETURN)
....................
....................
.................... #BIT RDPU=0xF84.7
.................... void main()
.................... {
0030: CLRF FF8
0032: BCF FD0.7
0034: CLRF FEA
0036: CLRF FE9
0038: MOVF FC1,W
003A: ANDLW C0
003C: IORLW 0F
003E: MOVWF FC1
0040: MOVLW 07
0042: MOVWF FB4
....................
.................... RDPU=1;
0044: BSF F84.7
.................... delay_ms(1);
0046: MOVLW 01
0048: MOVWF 06
004A: BRA 0004
.................... }
004C: BRA 004C
Configuration Fuses:
Word 1: 0C00 NOIESO NOFCMEN HS PLL1 CPUDIV1 NOUSBDIV
Word 2: 1E19 NOBROWNOUT NOWDT BORV20 NOPUT WDT32768 NOVREGEN RESERVED
Word 3: 8300 PBADEN CCP2C1 MCLR NOLPT1OSC RESERVED
Word 4: 0000 NOSTVREN DEBUG NOLVP NOXINST NOICPRT RESERVED
Word 5: C00F NOPROTECT NOCPD NOCPB
Word 6: E00F NOWRT NOWRTD NOWRTC NOWRTB
Word 7: 400F NOEBTR NOEBTRB |
|
|
|
Ttelmah Guest
|
|
Posted: Tue Jan 30, 2007 10:29 am |
|
|
The pullups, require the port to be configured for dgital I/O. Every bit of port D, is multiplexed to the PSP peripheral, and this needs to be turned 'off', before the pull-ups can be enabled. Also the high few bits share with the ECCP.
setup_psp(PSP_DISABLED);
setup_ccp1(CCP_OFF);
should allow the pullups to work. They are _weak_ though (typically 50uA).
Best Wishes |
|
|
JED
Joined: 13 Jul 2006 Posts: 8
|
|
Posted: Wed Jan 31, 2007 7:08 am |
|
|
Thanks for the reply Ttelmah. I did what you said and it works! The RDPU bit still always reads 0 but I have tested my board with a volt meter and when I set RDPU all pins on port d get pulled high and when I clear RDPU I read 0V, so it appears the pullups are working.
Best Regards. |
|
|
Ttelmah Guest
|
|
Posted: Wed Jan 31, 2007 11:27 am |
|
|
If you look at section 10.5 of the data sheet, and the diagram below, entitled 'Register 10-1 PORTE register', you will see that the top bit is shown as 'R-0' - means it always 'reads' as a zero.
Best Wishes |
|
|
metalm2 Guest
|
|
Posted: Tue Apr 24, 2007 4:28 pm |
|
|
You have bad mapped the RDPU bit, because you direction this to PORTE and it must be in the TRISE register
so you must put in place of #BIT RDPU=0xF84.7, the corresponding: #BIT RDPU=0xF96.7
I do this, but i cannot activate pull ups, PORTD stands in HI impedance mode...
Another BUG detected in PCWH 3.222: When you use the PORT_B_PULLUPS(TRUE) function, this writes in a memory location that is wrong, because the bit RBPU is in INTCON2 and the functions writes in TRISE.5 that is a non-implemented register.
i already don't know why i still using this compiller... |
|
|
metalm2 Guest
|
|
Posted: Tue Apr 24, 2007 4:57 pm |
|
|
correction:
the functions that works bad isn't port_b_pullups(), that is "setup_psp(PSP_DISABLED)" because this writes in F96.4 (TRISE register, bit 4) instead of the SSPCON register. |
|
|
metalm3 Guest
|
|
Posted: Tue Apr 24, 2007 9:14 pm |
|
|
correction 2: RDPU is in PORTE (i was thinking this is in TRISE)
i am a living bug but i am sure that the "setup_psp(psp_disabled)" function is wrong because this writes in 0xF96.4 and that is an unused bit....... |
|
|
|