• AVR Freaks

Helpful ReplyHot!_CNxPUE does not work

Author
antal_peter
New Member
  • Total Posts : 27
  • Reward points : 0
  • Joined: 2013/10/27 00:08:03
  • Location: Hungary
  • Status: offline
2019/11/01 10:08:47 (permalink)
0

_CNxPUE does not work

Hi,
I use dsPIC33FJ156GP506A  pull up command:
 
_CN1PUE = 1;
_CN2PUE = 1;
_CN3PUE = 1;
_CN4PUE = 1;
 
and I measure the corresponding input voltage value on RD8, RD9 RD10, and RD11 after the four PUE commands:
0.00V; 0.00V; 0.00V; 0.00V; if I touch with my finger i can reach 0.64V on all input, but no pull up. The corresponding CNPU1 register shows the pullup state is 1's
What is wrong?
#1
ric
Super Member
  • Total Posts : 25215
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: offline
Re: _CNxPUE does not work 2019/11/01 14:42:27 (permalink)
0
Sanity check. You never mention actually setting the pin to be an input. Are you sure it's not in output mode?
 
It's much more useful to show the entire test application, not just the snippet where you think the problem is.
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#2
antal_peter
New Member
  • Total Posts : 27
  • Reward points : 0
  • Joined: 2013/10/27 00:08:03
  • Location: Hungary
  • Status: offline
Re: _CNxPUE does not work 2019/11/02 02:50:04 (permalink)
0
I wrote a test:
 
/*
* File: main.c
* Author: Antal Péter
*
* Created on 2018. március 8., 14:14
*/
#include "xc.h"
#define BUTTON1 !_RD11 // IC4
#define BUTTON2 !_RD10 // IC3
#define BUTTON3 !_RD9 // Közös az LCD R/W bemenetével!!!
#define BUTTON4 !_RD8 // IC1
 
int main(void) {
TRISD=0xfff;         // All input
_CN1PUE = 1;
_CN2PUE = 1;
_CN3PUE = 1;
_CN4PUE = 1;
return 0;
}
 The result same.
#3
ric
Super Member
  • Total Posts : 25215
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: offline
Re: _CNxPUE does not work 2019/11/02 03:10:53 (permalink)
0
Where are the CONFIG settings?
Never, ever let the main function exit in an embedded environment.
Before the "return 0;", insert:
  while (1);  // loop forever

 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#4
du00000001
Just Some Member
  • Total Posts : 3314
  • Reward points : 0
  • Joined: 2016/05/03 13:52:42
  • Location: Germany
  • Status: offline
Re: _CNxPUE does not work 2019/11/02 03:14:48 (permalink)
0
The datasheet is somewhat meager about the CNxPUE.
Might be it requires the corresponding CNxIE to be set as well to work.

PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
#5
entra
New Member
  • Total Posts : 7
  • Reward points : 0
  • Joined: 2010/06/15 15:49:20
  • Location: 0
  • Status: offline
Re: _CNxPUE does not work 2019/11/02 03:41:48 (permalink) ☄ Helpfulby antal_peter 2019/11/02 04:23:57
5 (1)
Check Data sheet, Those pins are not CN Pins.
They are  IC - Input Capture.  No Pullups
See sections12 and Section10 below
 
https://www.microchip.com/wwwproducts/en/dsPIC33FJ256GP506A
 
 
#6
antal_peter
New Member
  • Total Posts : 27
  • Reward points : 0
  • Joined: 2013/10/27 00:08:03
  • Location: Hungary
  • Status: offline
Re: _CNxPUE does not work 2019/11/02 04:22:37 (permalink)
0
Entra you right!!
 
IC has no pull up function!
 
Thanks
#7
Howard Long
Super Member
  • Total Posts : 742
  • Reward points : 0
  • Joined: 2005/04/04 08:50:32
  • Status: offline
Re: _CNxPUE does not work 2019/11/02 05:36:37 (permalink)
0
Here's a test I ran successfully on a dsPIC Starter Kit 1 DM330011 populated as standard with a dsPIC33FJ256GP506. When you press SW1 (active low) it turns on the pull up CN3 on pin 15, which I probed with a 10x scope probe.
 


// DSPIC33FJ256GP506 Configuration Bit Settings
// 'C' source line config statements
// FBS
#pragma config BWRP = WRPROTECT_OFF // Boot Segment Write Protect (Boot Segment may be written)
#pragma config BSS = NO_FLASH // Boot Segment Program Flash Code Protection (No Boot program Flash segment)
#pragma config RBS = NO_RAM // Boot Segment RAM Protection (No Boot RAM)
// FSS
#pragma config SWRP = WRPROTECT_OFF // Secure Segment Program Write Protect (Secure Segment may be written)
#pragma config SSS = NO_FLASH // Secure Segment Program Flash Code Protection (No Secure Segment)
#pragma config RSS = NO_RAM // Secure Segment Data RAM Protection (No Secure RAM)
// FGS
#pragma config GWRP = OFF // General Code Segment Write Protect (User program memory is not write-protected)
#pragma config GSS = OFF // General Segment Code Protection (User program memory is not code-protected)
// FOSCSEL
#pragma config FNOSC = FRC // Oscillator Mode (Internal Fast RC (FRC))
#pragma config IESO = OFF // Two-speed Oscillator Start-Up Enable (Start up with user-selected oscillator)
// FOSC
#pragma config POSCMD = NONE // Primary Oscillator Source (Primary Oscillator Disabled)
#pragma config OSCIOFNC = OFF // OSC2 Pin Function (OSC2 pin has clock out function)
#pragma config FCKSM = CSECMD // Clock Switching and Monitor (Clock switching is enabled, Fail-Safe Clock Monitor is disabled)
// FWDT
#pragma config WDTPOST = PS32768 // Watchdog Timer Postscaler (1:32,768)
#pragma config WDTPRE = PR128 // WDT Prescaler (1:128)
#pragma config WINDIS = OFF // Watchdog Timer Window (Watchdog Timer in Non-Window mode)
#pragma config FWDTEN = OFF // Watchdog Timer Enable (Watchdog timer enabled/disabled by user software)
// FPOR
#pragma config FPWRT = PWR128 // POR Timer Value (128ms)
// FICD
#pragma config ICS = PGD1 // Comm Channel Select (Communicate on PGC1/EMUC1 and PGD1/EMUD1)
#pragma config JTAGEN = OFF // JTAG Port Enable (JTAG is Disabled)
// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
#include <xc.h>

int main(void)
{
TRISDbits.TRISD8=1; // SW1
while (1)
{
CNPU1bits.CN3PUE=!PORTDbits.RD8; // Reflect state of SW1 on pull up.
}
return 0;
}

#8
Jump to:
© 2020 APG vNext Commercial Version 4.5