Using microcomputer pin alternate functions - microcontroller

I hope this isn't too general a question, but how does one use an alternate pin function when programming a microcomputer. Specifically, does one have to "tell" the microcomputer that you're using the pin for a function other than its default. I realize that it's done, in effect, when one sets up SPI or I2C, for example, but is it language specific, so that in C/C++ one has to specifically identify the function one is going to use in some fashion. So, for GPIO (or whatever the default function is) one doesn't have to do anything, but if one wants to use a pin's alternate function 3 (let's say it's U2-RXD one has to communicate that explicitly to the microcontroller? Pardon the "stupid" question.

I'll take "it depends" as the definitive answer and defer to the datasheet for follow-up.
Thanks.

Related

How to implement sampling in ns3?

I wonder how to implement sampling in ns3. What exactly I want to implement is to create a simple network of switches and hosts using p2p links. Then, setting a probability (lets say 0.1) for an specific switch and expecting that every packet passing the switch will be captured with probability that I defined earlier. (Pretty much like the sampling in sflow or netflow).
I browsed nsnam.org, and the only tool I found regarding my question is Flow Monitor which I think is not helpful for my purpose.
There isn't a direct way to implement the behavior you want, but there is a solution.
Set up a normal hook to get all packets going through one of the switches. Refer to the tutorial to learn how to use the tracing system.
Then, use a RandomVariable at the beginning of your function to determine whether you want ignore that packet or not. The RandomVariable will need to be in global scope or passed in as parameter to the function.

Which language allow me to change the value of a parameter of a function?

And, is the language of Arduino one of them?
I am really curious about this ;)
Not exactly sure what you're asking here, but in nearly every language you can change or define function parameters.
I would also recommend taking a beginning programming course, as this would teach you the basics of such principles.
The code you use in the Arduino IDE is mostly C++ with a bit C, so yes you can change the value of a parameter or function.
And you should really read some programming principles first, before you even touch on the Arduino, like #WillLangas said.

MPI inter communication: What is the peer communicator?

I'm trying to understand how to use MPI_Intercomm_create to create a communication handle from one group to another. These two groups are also written in their own C files so there is no way of one group directly accessing the other's communication handle unless I use a global variable or the like. How do I get the "peer_comm" (3rd argument of the call) for the other group? Or am I just not understanding something?
MPI_Intercomm_create() operates on communicator (e.g. MPI_Comm) and not on groups (e.g. MPI_Group) so let's use the right semantic here.
If you launch several binaries with the same mpirun command line, then they are all in MPI_COMM_WORLD, and this is likely what you want to use for peer_comm.
If you use MPI_Comm_spawn() in order to launch "the other binaries", then it returns your inter communicator, so you likely do not even need MPI_Intercomm_create().
I strongly encourage you to write a Minimal, Complete, and Verifiable example. Not only it will help you clear some confusion, you will more likely get a precise answer once the issue is clearly stated.

How to convert lpc interface to serial on arduino

As a hardware illiterate software guy trying to do a hardware prototype, will appreciate an answer to this.
One of the hardware components that I need to integrate supports only lpc interface. Is there a way to have it work with arduino? Does the question even make sense? What are my options with this?
I tried doing a bit of research on this, but simply didn't understand anything, nor was there any direct reference to anything that makes this possible.
I guess you're talking about Intel's Low Pin Count protocol.
And I guess, you're trying to make a BIOS flasher, aren't you? ;-)
Is there a way to have it work with arduino?
yes
Does the question even make sense?
of course
What are my options with this?
Have a look at that article and this thread… It shows and gets into some details in how to implement it.
As you say you're a software guy, just consider that you're trying to implement some kind of network procotol stack, starting from the basic building blocks. You need to take care of sending the bits over the pins, take care of the timings, output the start/end stop flags if there are… And then implement a buffer on top of that to parse a byte, and then bytes, etc…
All you need to do that is to follow the sepecification, and plug a few pins on the Arduino.
Well, your question should be closed for lack of research effort, but hence you say you tried but are still lost, I hope my insights will help you come back and ask a real on-topic question with something you actually tried.
HTH

A way to change mcu program from the outside

We need to change a controller code from the out side as they do with industrial MCU .
So that you have an mcu,with a program on it, and someone can program some "words" to it, that will determine how it works.
So for example you can program an mcu -not with a programer but with some inputs from serial, to do some simple things such as:
if input A==1
b=1
I wonder if there is a smart way to do that with simple software on the mcu, that it has many #defines for various commands, and it perform them according to values it gets from the outside (and saved for the rest of the program).
I wonder if the industrial programers are using that method, or that every programing of a user is actually load a code(.hex) to the chip(with internal programer ) .
I prefer the simplest way(i wonder if its by pre defined software)
A couple of options come to mind so hopefully this answers your question. It sounds like the simplest version of your question is "How do I change the behavior of the MCU without an actual MCU programmer?" A couple of options come to mind.
1) Depending on the MCU you can have a bootloader that is essentially a small piece of code programmed in the MCU by a programmer that has the ability to reprogram other parts of the MCU. This doesn't require a programmer but involves some other form of letting the bootloader know what the new code is (USB, Serial, SD Card, etc). This will only work if the MCU has the ability to self flash.
2) Again, depending on MCU and scenario you could program a generic set of rules that carry out functionality based on the inputs given to the MCU. This could be in the form of IO pins, EEPROM, or a domain-specific script on an SD card that the MCU can read and interpret at runtime.
Both options depend on the MCU you are using and what hardware capabilities you have at your disposal. But you certainly have options other than reprogramming the end hardware with an actual programmer every time you want to make a change. Hopefully that helps.

Resources