problem with pin PA22 on ATSAMD10D14A-S - Page 1
Forum section: electronics / general

author: FrankBuss
author_rank: Unknown
timestamp: January 24, 2021, 02:35:50 am
content: I created a project with Microchip Studio, based on theGetting Startedtutorial, with this code from the PDF:Code:int main(void){PORT->Group.DIRSET.reg = PORT_PA09;while (1){if (PORT->Group.IN.reg & PORT_PA25){PORT->Group.OUTSET.reg = PORT_PA09;}else{PORT->Group.OUTCLR.reg = PORT_PA09;}}}and it works. But when I use PA22 instead of PA25, it doesn't work.Thedatasheetsays on page 13, all pins can are configured as GPIO by default, and I can't find anything different for this pin, but maybe I missed it somewhere in the 918 pages. I can even use e.g. the SWDIO pin, with which I program the chip, as GPIO after programming. But in the pin table the pin PA22 is listed as "type: I2C". Is it impossible to use the I2C pins as GPIO?I tried to use PA22 as output, and this works. So looks like it is output only possible for the GPIO configuration for this pin.

author: ataradov
author_rank: Super Contributor
timestamp: January 24, 2021, 03:00:53 am
content: You need to set INEN bit in the PINCFG register. I'm not sure why different pins would behave differently, but enabling the input buffer is a requirement.All pins can be used as I/O. I2C just indicates higher drive strength compatible with I2C spec.

author: FrankBuss
author_rank: Unknown
timestamp: January 24, 2021, 04:21:38 am
content: Thanks, works now.But right, it is interesting why PA25 works without setting this bit. And the "Getting Started" PDF is then very misleading, because they are using some kind of undefined behavior, which resulted in some hours debugging for me. But my fault, I should really read the whole datasheet, nice evening reading to get some nightmares about registersI also looked at the startup code and couldn't see anything.But looks like PA24 and PA25 are different. I can see this comment in the datasheet:QuoteInterestingly, this chip doesn't have USB. Maybe it is the same die as for some bigger chips with USB, and then they just disable USB with some fuses.

author: ataradov
author_rank: Super Contributor
timestamp: January 24, 2021, 04:26:19 am
content: This note in the D10 datasheet is a mistake, it is a copy from the D11. D10 is a separate die that has no USB, even disabled. This was reported some time ago, and once someone gets around to updating the datasheet it would be gone.

author: FrankBuss
author_rank: Unknown
timestamp: January 24, 2021, 04:38:21 am
content: Ok, but there is another note:QuoteIs this also wrong? This would be useful to know, to save 1 mA. But no big deal to enable the pullups anyway, it doesn't hurt even if the note is wrong.

author: ataradov
author_rank: Super Contributor
timestamp: January 24, 2021, 04:46:38 am
content: Yes, this also does not apply. PA24 and PA25 are no different from other pins in this device.Also, I think that 1 mA only happens on some edge cases, like enabled USB with a sleeping device or something like that.

author: FrankBuss
author_rank: Unknown
timestamp: January 24, 2021, 05:13:52 am
content: Well, something is different for the pins, because PA24 works without setting the INEN bit (and probably PA25 as well, didn't test it). I single stepped it in the debugger and displayed the value of PORT->Group.PINCFG.bit.INEN in a watch window, and it was 0 all the time (so no startup code or reset condition sets it), but the PORT->Group.IN.reg still changes, when I change the external voltage, as initially observed. This doesn't happen with PA22, unless I set the INEN bit for it.

author: ataradov
author_rank: Super Contributor
timestamp: January 24, 2021, 05:27:28 am
content: It is possible that being I2C pad makes it different in design. It is generally normal, if you don't enable the input buffer the behavior is not really defined.

author: FrankBuss
author_rank: Unknown
timestamp: January 24, 2021, 05:39:39 am
content: PA24 and PA25 are not I2C pins. But maybe they tweaked the silicon, so that the "Getting Started" tutorial works

author: ataradov
author_rank: Super Contributor
timestamp: January 24, 2021, 05:40:53 am
content: But PA22 is. I assume may be something is enabled on I2C pins. No idea really.

author: FrankBuss
author_rank: Unknown
timestamp: February 19, 2021, 10:10:24 am
content: I got an answer from the Microchip support, and they confirm that it is a silicon bug that PA24 and PA25 does work without the INEN bit.But the interesting part, they also wrote the following in the answer:QuoteTheirAtmelMicrochip Studio product pagedoesn't mention this. Maybe they plan to discontinue Studio? This would be too bad, I really prefer this over MPLAB-X, but understandable that they want to maintain only one dev tool.Never used Harmony so far. Sounds like some fluffy clicky GUIy thingy, which produces unnecessary bloated and slow code

author: ataradov
author_rank: Super Contributor
timestamp: February 19, 2021, 05:16:05 pm
content: There will be no new MCU support added to the Studio. 8-bit MCUs will continue to be supported. Hence the full name of the renamed package.