Reputation: 120
Using the RPOR registers, I can successfully connect RB3 or RB15 or other pins to a UART (1-4) ... but not RB6. I don't see anything in the documentation or errata that say RB6 (RP6) is uniquely unavailable. Any guesses?
Here are my RPOR registers when I have RB3, RB6, and RC3 all connected to UART0. RB3 and RC3 operate correctly, but RB6 only operates as a digital output.
03D6 RPOR0 0x0000 0 00000000 00000000 '..'
03D8 RPOR1 0x0300 768 00000011 00000000 '..'
03DA RPOR2 0x0000 0 00000000 00000000 '..'
03DC RPOR3 0x0003 3 00000000 00000011 '..'
03DE RPOR4 0x0000 0 00000000 00000000 '..'
03E0 RPOR5 0x0000 0 00000000 00000000 '..'
03E2 RPOR6 0x0000 0 00000000 00000000 '..'
03E4 RPOR7 0x0000 0 00000000 00000000 '..'
03E6 RPOR8 0x0000 0 00000000 00000000 '..'
03E8 RPOR9 0x0300 768 00000011 00000000 '..'
03EA RPOR10 0x0000 0 00000000 00000000 '..'
03EC RPOR11 0x0700 1792 00000111 00000000 '..'
03EE RPOR12 0x0008 8 00000000 00001000 '..'
Here is how PORTB is set up:
018A TRISB 0x22A2 8866 00100010 10100010 '"¢'
018C PORTB 0x00C8 200 00000000 11001000 '.È'
018E LATB 0x0040 64 00000000 01000000 '.@'
0190 ODCB 0x0000 0 00000000 00000000 '..'
0192 ANSB 0x2000 8192 00100000 00000000 '..'
... and here are the CONFIG bits:
_CONFIG1(JTAGEN_OFF & GCP_OFF & GWRP_OFF & ICS_PGx1 & FWDTEN_ON & WINDIS_OFF & FWPSA_PR128 & WDTPS_PS1024);
_CONFIG2(IESO_ON & WDTCMX_LPRC & FNOSC_FRC & FCKSM_CSDCMD & OSCIOFCN_ON & POSCMD_NONE)
_CONFIG3(SOSCSEL_ON)
_CONFIG4(IOL1WAY_OFF & PLLDIV_DISABLED & DSWDTPS_DSWDTPS15)
I am trying to get on the Microchip fora to ask this, but their registration process is apparently down. Hoping the good folks of StackOverflow can help. Thanks!
Upvotes: 2
Views: 281
Reputation: 1
I contacted Microchip support and they got back to me in a time considerably shorter than that of proton decay (about a day) with a solution which works.
Bit 11 of FLASH CONFIGURATION WORD 2 (reserved, reset value=1) has to be cleared by appending & 0xF7FF to the config2 setting, like this:
_CONFIG2(POSCMD_NONE & WDTCLK_FRC & OSCIOFCN_OFF & FCKSM_CSDCMD & FNOSC_FRC & ALTCMPI_CxINC_RX & WDTCMX_WDTCLK & IESO_OFF & 0xF7FF)
You will have to live with the compiler warning "consider migrating to #pragma config". The #pragma syntax seems to take text arguments, so really doesn't want you to go flipping undocumented bits.
Quite why peripheral outputs on RB6 are disabled by an undocumented (outside Microchip) bit is beyond me.
Quite why Microchip (or whoever designed the Demo board) chose to use RB6 as TX to the mikroBUS™ Interface is beyond me.
Upvotes: 0
Reputation: 1225
Microchip, with infinite and God like wisdom, decided to have analog input functionality on the RB6 input but suppress almost all documentation of this and remove any mention of this in the PIC24FJ128GA204 errata.
The the data sheet has vague hints about this here:
And here:
To get what you need clear ANSB bit 6 to zero.
Upvotes: 2