Port configuration problem with 32A4

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm trying to configure pins 5-7 on port C as totem-poles with pullup resistors. They're pulled low one at a time by a 1P3T switch. It seems to me that, until pulled low, each should read high, but as you can see in the attached screen grab (1.jpg) from AS 4.19, PORTC.OUT 5-7 are all high, but PORTC.IN 5-7 are all low. This stays the same regardless of switch position. The voltage read on these pins is .6V at the CPU, which also seems odd since VCC = 3.3V.

I do have an 8-bit level translator between the switch and the CPU, so there could be a problem with it, but the other 5 bits (connected to other stuff) are translating correctly. On the other hand, I'm not using pullups on the other bits.

Also, port E (which only has 4 bits) works fine when configured identically with pullups (as you can see in the screen grabs), but there's no level translator on it (see second screen grab, 2.jpg, taken one instruction after the breakpoint).

I'm hoping there's some other issue I should explore that won't require me to replace the translator. Any thoughts? Thanks.

PS - You may have to open the jpgs in another tab or window for them to be big enough to read.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Change those pins to output instead of pullup. Measure then the voltage at those pins and also measure the total current taken by the CPU. If you don't get close to 3.3 V and no change in current while setting those pins 0->1, you have a problem in your switch or level translator.

You can also try to measure the current change with pullups, but then the currents will be very small.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I replaced the level translator and I still have the same problem. I'll try some different port configurations next.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Totem-pole is an OUTPUT config . It sounds like you only need input-handling from the switches, so just config. for direction = inputs and enable the pullups . Forget totem-pole .

PORTC_OUTSET = 0xe0; // Enable pullups.

Wrong ! Man this ain't no Mega/Tiny series MCU. R-RTM , I/O section especially about the MPCMASK register ( then you'd only need ONE write to a PINxCTRL register for ALL pins concerned ) .

1) Studio 4.18 build 716 (SP3)
2) WinAvr 20100110
3) PN, all on Doze XP... For Now
A) Avr Dragon ver. 1
B) Avr MKII ISP, 2009 model
C) MKII JTAGICE ver. 1

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks, indi, but I think totem-pole can be either input or output. From the Xmega A Family Manual:

Quote:
13.4.1.2 Totem-pole with Pull-up
In this mode, the configuration is as for Totem-pole, except the pin is configured with internal pull-up when set as input.

Regardless, removing the totem-pole configurations doesn't solve my problem.

Also, I'm using PORTC.OUTSET, not PORTC_OUTSET. I believe the former is the correct form for Xmega.

I forgot about the MPCMASK register, so I'll reread that, but that's really just a convenience (I've got plenty of memory). I'll keep plugging.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Lautman, the manual A quote means you have to switch between the pin being in/out, when it's set to such a dual config. But I doubt your app is changing direction on those pins . :wink: Totem-pole is EXACTLY and ONLY used for what I stated .

You don't use the code line I mentioned to enable pullups and that line should be taken out . The Xmegas can handle the '.' or '_' notation for the I/O registers .

What voltage is the translator supposed to be translating, 5V ?

1) Studio 4.18 build 716 (SP3)
2) WinAvr 20100110
3) PN, all on Doze XP... For Now
A) Avr Dragon ver. 1
B) Avr MKII ISP, 2009 model
C) MKII JTAGICE ver. 1

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

> Wrong ! Man this ain't no Mega/Tiny series MCU.

Old habits die hard. If you don't enable pullups that way, and I shouldn't be using the totem-pole with pullup configuration, what should I be doing? The only mention of pullups on the I/O ports in the manual is in the pin configuration section where the only choices are totem-pole and wired-AND. The latter actually looks like it should work more cleanly, but the Fig. 13-7 suggests you write a 1 to the OUT register to activate the pullup, which you say is incorrect. In any event, it which works no differently on my h/w.

Still confused. Thanks for your help.

Oh, and yes, I'm translating 5V - 3.3V, bi-directionally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok, so to do pullup, Totem-pole "comes along with" that bit_group_configuration setting ( I just checked the *.h file. I thought they could be separate settings . ) . BUT there's no need to talk about T-P part of the setup SO LONG AS the pin is ALWAYS an input . Then T-P's is no factor in pin's behaviour . SO,

PORTC_DIRCLR = 0xE0;
PORTCFG_MPCMASK = 0xE0; // Between these 2...
PORTC_PIN5CTRL = PORT_OPC_PULLUP_gc; //...statements, PC5-PC7 will have p.ups enabled .

I've used the 1 line of PINxCTRL to setup pullups in the past and it works right, and there's nothing else to do .

Figure 13.7 is a config. that doesn't apply to what you're doing so it's nothing to worry about . But yes you would have to write that '1' to setup p.up ( FOR THAT config. ) . Fig. 13.4 is what you want, and see that it's the DIR register that needs clr'ing, NOT the OUT register being set .

I would test the translators with nothing on the 3.3V side but a DVM and make sure it's working by outputting 3.3V and 0V for the 3 switches . If it's working, then I'd test the 3 MCU pulled_up pins hooked up directly to 3.3V switch inputs and see if they behave .

I've never used translators, but they must do 5V -> 3.3V and
0V -> 0V ( is this one right ? ) . What interface conditions are required on the low side between the chip and MCU and are they being met ( To be asked only if both tests above pass ) ?

1) Studio 4.18 build 716 (SP3)
2) WinAvr 20100110
3) PN, all on Doze XP... For Now
A) Avr Dragon ver. 1
B) Avr MKII ISP, 2009 model
C) MKII JTAGICE ver. 1