GPxPUD register values in C2000 F28035 c28x_LedBlink_ert Simulink Example

F28035 simulink example file: "c28x_LedBlink_ert" After the program was loaded, I clicked on the "Open project in Code Composer Studio" in the simulink "Diagnostic Viewer". In the CCS watch window, I was going through the register values and had a few questions:
1) In the CCS watch window for "c28x_LedBlink_ert" "GPAPUD" by default has a value 0x00000FFF (pull up disabled for GPIOs 0 to 11, which are PWMs), similarly "GPBPUD" has a default value of 0x00000300 (pull up disabled for GPIO 40 & 41, again these are PWMs). However I can't seem to find the file that initializes the registers with the mentioned values, the only file initializing the "GPxPUD" register is in fact the "DSP280x_Gpio.c" file which initializes the pull ups using the following two lines:
GpioCtrlRegs.GPAPUD.all = 0x0000; GpioCtrlRegs.GPBPUD.all = 0x0000;
So there has to be another file overwriting these registers, could I be directed to that file/function?
2) The "c28x_LedBlink_ert" toggles the GPIO pins 31 & 34, so that means that those GPIOs should be set as outputs, again looking at the watch window I observe that "GPADIR" has a value of 0x80000000 (i.e. GPIO 31 = output) and "GPBDIR" has a value of 0x00000004 (i.e. GPIO 34 = output), so things are fine. However shouldn't the pull ups be disbaled since these are outputs? Shouldn't "GPAPUD" be 0x80000FFF and "GPBPUD" be 0x00000304?
Thanks in advance

Answers (1)

Hi Alex,
We don't initialize the pull-up registers and the default values after reset are not uniform across the different registers. The value you see for GPAPUD (0x00000FFF) corresponds to the value after reset. Look at Figure 63 of the following document:
Figure 64 shows the GPBPUD and the value 0x00000300 is also the value after reset.
I would agree that once the pin is driven as an output, the pullup is just a waste, though not harmful.
You can initialize the pullup registers using the following custom code block:
We will consider removing pullup for outputs in future releases.
Thanks for your input.
Antonin.

5 Comments

Thank you for your reply Antonin,
It would be much appreciated if you could also answer a few follow up questions. I feel like they are probably questions that should be directed at TI but if you could shed some light, it would be very helpful.
1) I had already gone through the document you recommended (TI - sprugl8c) and did observe that the GPxPUD registers will have the discussed values after reset (I even created a blank file in CCS with no header files linked to it - only a blank main.c file, the only knowledge the tool had was the target configuration, based off of that, the registers were initialized to their correct state).
I wanted to know if the user can actually open the file which initializes all the registers to their default values. I read the following information: http://processors.wiki.ti.com/index.php/GEL#Startup_Files which suggests there is indeed a file/script responsible for this. I checked the .gel file for the F28035 and could not find the information I was looking for.
2) As for my second question, you mention that the pull up for an output pin should be disabled but it is not harmful to leave it enabled. Based on the literature survey I have done, TI mentions that the pull up network does not actually have a passive resistor in place but rather an active circuit.
So, is that pull up enable circuit a "smart" circuit which can actually disable the pull up if it senses contention on a pin? Is there some feedback on the CMOS circuitry itself which can disable it (because the registers don't reflect that the pin is pull up disabled)?
These questions could be me just nitpicking, but they were doubts in my mind that I was hoping to get cleared.
Thank you
1) I don't think that you can control the default reset value of registers via software. The GEL files allow initialization from CCS on certain actions like "connect to target", but this is post reset and can't be used in standalone mode.
2) From my understanding, it's not smart, I would think that the pullup consumes a bit of energy when the pin is low and set as an output. One way to prove this would be to set all of them as output low and look at the device consumption when pullups are enabled and disabled. Let us know if you see a difference :-)
Once again, thanks for your reply Antonin.
1) After posting a thread on the TI E2E community, I was given the following response in regard to a file that initializes the register:
"The default register values are handled in hardware not software...It also may be worth saying that they're not configurable."
2) I did a quick test on the current drawn by the controller under the following conditions:
- All GPIOs set as outputs
- All GPIOs set to 0V
- All GPIO mux registers set to 0x00000000
Device Used: F28335 (has more GPIOs - which help in observing a greater difference between the current drawn for the two scenarios)
(a) First, the pull ups were disabled:
The current drawn is 175mA
(b) Next, the pull ups were enabled: possible short circuit path?
The current drawn is 184mA
From the watch windows, one can observe that 88 GPIOs have their pull ups disabled and then enabled. The difference in the current drawn is:
184mA - 175mA = 9000uA
the current increase per GPIO pin = (9000/88)uA ~ 102uA
Based off the F28035 datasheet, that roughly puts us in the ballpark:
The way I connected the current sensor was as follows:
Anyway, let me know your thoughts Antonin, you have been a great help so far.
PS: Are these videos made by you??
Great work, You proved it!
I shared your investigation with the team here, everyone loves it. People also think that you are a great photographer and that we should gift you with a new USB cable to thank you for the work :-)
On a more serious note, TI mentions in the documentation of the F2837x devices that input pins should not be left floating, which probably explains why they enabled the pullup by default on most F28335 pins except the ones that are dedicated to be outputs (i.e. PWM). On new devices, they disabled all pullups by default, which probably prompted them to add the warning.
We will investigate a way to configure the pullup registers in our tools. In addition to allowing the user to set the pullup, we can detect how pins are used to automatically set the pullup.
Thanks,
Antonin.
PS: Yes, these are my videos
Thank you Antonin,
The Mathworks forums have been a great place for me to explore and learn new things. Through this post I have had the opportunity to discuss an interesting concept which may also help other learners. To make things easy for others to understand, I added clear pictures and screenshots with what was trying to be achieved. It was a fun exercise :)
I appreciate you sharing the documentation from the F2837x family. I hadn't come across that documentation as my projects use the F28335 and F28035 devices.
I guess that is what I did in the "experimentation" part of this post, not advised by TI though.
Till there is a new release from Mathworks, users may want to do the following (as suggested by Antonin earlier in this post):
Select the block and place it in your simulink project with the following embedded code:
Sanity check: Verify through CCS watch window (GPIOs 31 and 34 have their pull ups disabled)
Thanks

Sign in to comment.

Categories

Find more on Simulink in Help Center and File Exchange

Products

Release

R2018a

Asked:

on 30 Aug 2018

Commented:

on 12 Sep 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!