Skip to main content

What Are Registers in embedded Rust?

 What Are Registers in embedded Rust?

What Are Registers in embedded Rust?

  •  Registers are type of computer memory.
  • They are reside near to CPU and used immediately by CPU.
  • Can hold data (bits of sequence), storage address (pointers) or instructions.
  • Registers holding the memory location are used to calculate the address of the next instruction.
  • In terms of MCU’s registers are special memory regions
  • These special regions map to or control some peripherals
  • And we already know we have many of them in our board
  • These peripherals are electronic components built in the MCU to provide its processor the ability to interact with IO devices.
  • We will be following code from this repository 
  • We are using raw pointer here for demonstration purpose. It’s not recommended to use in normal programs btw except in genuine case
  • Address (i.e. 0x48001018) points to a register
  • This register controls GPIO pins. GPIO is a peripheral
  • Also using GPIO we can drive the mapped pins to low or high

Light Emitting Diode (LED)

  • Pins are electrical contacts and our MCU has many of them
  • Few of them are connected to LEDs, few are connected to other devices on board
  • Once a pin connected to an LED in right polarity and a high voltage applied to that pin that's the only case LED will glow

Reading the Reference Manual (RTRM)

Whenever we start learning a new programming language, using a new hardware or buy a new cell phone. Its documentation/guide is must read/follow thing to take full advantage of that.

  • Manual says that MCU has several pins.
  • These pins are grouped in ports of 16 pins
  • Each port named with a letter (e.g. A, B, C,.., H)
  • Pins within each port named with a number (e.g. 0, 1, 2,.., 15)

Since we are interested in finding pins associated with LEDs, so let’s check the manual to find out those pins.

  • Manual says LD3 connected to PE9 and LD7 connected to PE11.
  • Here "PE" in PEXX represents the port name (i.e. Port E of GPIO peripheral)
  • The number after the port name represents pin number in the port.
  • Each peripheral has a register block associated to it.
  • A register block is a collection of registers allocated in memory contiguously
  • The starting address of this block called base address
  • Now we know to driving LEDs we need to manipulate with Port E registers. For that we need to find out the base address of Port E.

For finding base address of Port E we have to follow the reference manual. Little other information’s we extracted from the documentation:

  • Bits 0-15 can be used to set the corresponding pins (i.e. bit 0 sets pin 0 and bit 15 sets bit 15)
  • Also, bits 16-31 can be used to reset the corresponding pins
  • All seems to be in agreement when correlating that information with our program,Writing 1.

Popular posts from this blog

What is Internet of Things (IoT)?

 What is Internet of Things (IoT)?    The internet of Things, or IoT, refers to the billions of physical devices  round the  world that are now connected to  the web  , collecting, sharing and analyses  of knowledge  . It presents and provides the explanation of the network of physical things which is embedded with software , sensors,  and other technologies for the benefit of connecting and exchanging data with other devices and systems on the internet   . Due to the cheap processors and wireless networks, it's possible to  means  anything, from a pill to an aero plane to a self-driving car into  an area  of the IoT. Overview IoT will control the Fourth  technological revolution  . The Fourth  technological revolution  is changing the very software-defined automation allows manufacturers to link all stages of  the worth  chain, rapidly adapt to changing markets , and make highly personalized products on a mass scale. The opportunities provided by this revolution are authenticated

What is Rust Borrowing?

What is Rust Borrowing? Borrowing We call having references as function parameters borrowing. As in real world , if an individual owns something, we 'll borrow it from them . Whenever we’re done, we 've got to offer it back. Referencing  The reference is that the act of consulting somebody or something so as to urge information We would  declare reference in terms of Rust programing as if we are taking a replica of it without damaging or taking its ownership. ‘&’ symbol is employed to pass the reference Have a look that  how ‘&’ symbol is employed in code. fn main() { let s1 = String::from("hello"); let len = calculate_length(&s1); println!("The length of {} is {}.", s1, len); } fn calculate_length(s: &String) -> usize { s.len()} Mutable References The actual concept of mutable reference is same as we use mutable variable When  we  need to  modify  mutable reference is employed once   the worth we make regard to.

Kubernetes Readiness Probes

 Kubernetes Readiness Probes Description We understand that liveness probes and the way they assist keep our apps healthy by ensuring unhealthy containers are restarted automatically. Same like liveness probes, Kubernetes permit us to also define a readiness looked for our pod. The readiness probe is deployed periodically and examines whether the precise pod should receive client requests or not. Whenever a container’s readiness probe returns back success, it’s signaling that the container is ready to simply accept requests. This notion of being prepared is clearly something that’s specific to every container. Almost as liveness probe Kubernetes sends requests to container and supported the result either successful or unsuccessful response it decides container is prepared to require traffic or still preparing for that. The liveness probes not like, if a container fails the readiness check, it won’t be killed or restarted.   This is a very good practice to