Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
we are going to assign priority 5 to the Port F then we write the following code
int main() {
NVIC_PRI7_R |=0☓00A00000;
NVIC_EN0_R= 0☓40000000;
My question is that where does this code 0☓00A00000 this code came from?
The Nested Vectored Interrupt Controller (NVIC) registers are present in the ARM Cortex M architecture, so I am supposing that you are programming for that kind of target.
According to the ARM Cortex M manual:
The NVIC supports up to 240 interrupts, each with up to 256 levels of
priority that can be changed dynamically.The processor and NVIC can be
put into a very low-power sleep mode, leaving the Wake Up Controller
(WIC) to identify and prioritize interrupts.
The NVIC_PRI7_R variable is used to trigger the CPU in a given mode through specific registers manipulation. Setting it to a given value will make the CPU enter in a specific mode of priority (read the documentation for more).
About the 0☓00a00000, it acts as a mask to set a few bits to '1' in NVIC_PRI7_R. Precisely, 0x00a00000 == 0b101000000000000000000000, so the operation |= will set two bits to one and trigger the priority mode to 5 (note that 0b101 == 5). Read the ARM Cortex M manual to see that these very precise bits trigger the priority mode of the CPU.
Hope it helped you to understand a bit more this way of doing.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I'm a student and im currently learning the basics of microprocessors.
I've been assigned a task with no prior knowledge of the task itself and i've been struggling to find the answer to it. So i wanted to give it a shot on Stackoverflow.
The task is to write a simple program using the Programing language C to test the Arduino board which first initializes the 12th pin and afterwards continually gives pin 5V for 5 seconds and a low voltage in 0 for 1 seconds for the same pin.
For a humble solution or explanation for it i would be very happy.
Thank you in advance.
Edit:
Im referring to the Arduino Hardware.
Since the task is to set a certain pin as output, the first thing you need to do is to check the board schematics to find out which microcontroller port and pin that "pin 12" corresponds to. Microcontroller ports often have a 1 letter name such as PORTA, PORTB etc. This is also the case for AVR.
Once you have found out which port that's the correct one, you also have to figure out which bit in that port register to set. There will be 8 pins per port, since each port on this MCU corresponds to 8 bit registers.
Since you want this pin to be an output, you have to configure a "data direction register" to make it such. On AVR (and most Motorola-flavoured MCUs), these registers are called DDRx, where x is the port letter. See the AVR manual, GPIO section. You set the DDR register as output by writing a one to the bit corresponding to the pin.
Once that is done, you can set the relevant bit in actual port register to 1 or 0, depending on if you want a high or low signal. These are called PORTx on AVR.
To create a 5 second delay, it is likely enough for hobbyist/student purposes to call a "busy wait" function. The Arduino libs has the delay() function that should suffice. Simply wait 5000ms. In professional/real-world applications, busy-wait delays should be avoided and then you'd rather use the on-chip hardware peripheral timers instead, to set a flag when the timer has elapsed.
From your post I take that you have an Arduino board.
It is unlikely that someone told you to program it in C as you don't know any C. And programming that Arduino's AVR microcontroller bare metal in C is impossible of someone of your skill level.
So let's assume you're supposed to complete the indeed very simple task of programming an Arduino with the Arduino IDE in C++ to do what is asked.
All you have to do is follow this link:
https://www.arduino.cc/en/Guide
I won't give you any code as this would take away the learning experience from you.
You will have to configure pin 12 as a digital output.
You will have to find out how to set LOW and HIGH to a digital output
You will find out how to pause/delay your program for a number of seconds.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 2 years ago.
Improve this question
I am programming a Texas Instruments TMS320F28335 Digital Signal Controller (DSC) and I am writing the communication with a resolver model AD2S1205 (datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/AD2S1205.pdf). I have to implement the “Supply sequencing and reset” procedure and the procedure for reading and sending the speed and position values through the SPI serial interface back to the DSC. I'm new to firmware and there are several things I don't know how to do:
In the resolver datasheet (page 16) you are asked to wait for the supply voltage Vdd to reach its operating range before moving the reset signal. How can I know when this happened?
To ask the resolver to read and transmit the position and speed information, I must observe the time diagram (page 15), e.g. before putting /RD = 0 I have to wait for /RDVEL to remain stable for t4 = 5 ns. What should I insert in the code before the instruction that lowers RD to make sure that 5 ns have passed? I can pass 0,005 to the DELAY_US(A) function available on the DSC (which delays for A microseconds) but I don’t know if it will actually work and if this is the right way to go to observe device timing diagrams.
In the “/RD input” section (page 14) it is specified that the high-to-low transition of /RD must occur when the clock is high. How can I be sure that the line of code that lowers /RD is running when the clock is high?
Connect chip Vdd to the ADC port via the divider. Reset the chip when Vdd is correct.
Your uC is 150MHz. The clock period is 6.67ns which is larger than 4ns required. Whatever you do you cant change the pin faster. Problem does not exist for you.
Connect CLKIN to the input pin. Poll it. Change /RD when clock high
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
In the arm architecture which registers to update the address of ISR to the programme counter.
Does in GIC or vendor IC(like Ti, NxP) there is any hardware logic that provides ISR instruction address to the program counter?
ARM CPUs use a so called vector table. It's an area in memory that contains the start addresses of all exception handlers aka ISRs.
So if the vector table starts at 0x08000000 and the Systick exception occurs, the CPU interrupts the current work and loads the Systick ISR start address into the program counter (PC). It can be found at 0x08000000 + 4 * 15 (as Systick has exception number 15).
Before PC is loaded, several registers (incl. PC) are saved on the stack.
The address of the vector table is configured via the VTOR register.
Exceptions 0 to 15 are given by the ARM architecture and are the same for all CPUs and MCUs. Exceptions numbers 16 and higher are vendor dependent and usually used for hardware related events such as UART, SPI, DMA events.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
In STM32F101 with some mishap with the reset, BUSY flag is held high. To come out of it, I followed the steps given in page 26 of following document from STM :
https://www.st.com/content/ccc/resource/technical/document/errata_sheet/7d/02/75/64/17/fc/4d/fd/CD00190234.pdf/files/CD00190234.pdf/jcr:content/translations/en.CD00190234.pdf
While doing the steps,I could able to do the 1st step. In the second step (Set SCL and SDA as open drain output with their values high) , I have set both SCL and SDA as output open drain, but could if I set the pins high, only SCL's IDR register is set high and SDA pin's IDR register could not be set (but it's ODR register is set). Because of this I could not able to continue with further steps. Please help me through this
This not the issue in this case. The slave device is keeping the SDA low. To exit from this deadlock you need to provide between 8 and 12 clocks. You need to toggle the SCL pin, and after every clock you need to check if the SDA line has been released by the slave device. This has nothing in common with this errata.
After this is good to reset the I2C peripheral.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am new to microprocessor programing and currently have a RGB sensor which reads an RGB value and increments a variable by an arbitrary number. I want the sensor to turn off for 0.3 seconds when I reach a certain value. Is there a way to do this or will I have to figure out a different way to throw out all the values the RGB sensor receives during that 0.3 second time span? I am writing in C.
Note: The sensor I am currently using is a TCS230.
According to the datasheet pin #3 is Output Enable ('OE, active low). So if you drive this pin high it should cut off the chip's output.
Or more to your question, it looks like if you drive pins S0 and S1 both low, it will place the chip in a "Power Down" state.
Whichever option you choose depends on what's more important. Do you want quickest reaction time, or do you want to conserve power? If you want the quickest reaction time, use 'OE. There is a typical 100ns delay between asserting this signal and the chip responding. The downside is the chip is still running during this whole time. If you choose the Power Down state, then you will save energy vs the Output Enable option, but the photodiodes have a typical 100 microsecond "recovery from power down" delay. Obviously that's a factor of 1000, and if you're doing time-critical work, probably not the best option.
Keep in mind, I have never used this chip in my life, just basing my answer a quick read of the datasheet.