Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

should I know all of the registers of a MicroController?

Status
Not open for further replies.

rezaeee

Junior Member level 1
Joined
Oct 3, 2015
Messages
19
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
265
Hi,
I'm newbie in electronics, and I'm confused with registers of Micro's. I've counted the registers of the lpc213X series, and was about 200!! so I think for bigger Micros like lpc1768 it goes up by factor of 2!
So, if I want to program Microcontrollers, should I know all of their registers? and If I want to choose another micro from other companies, I should learn all of their registers too from the first?

What about the CMSIS? Has it same function from all cortex-m based micros of all companies? or it's different implemented in each micro or company?
 

So, if I want to program Microcontrollers, should I know all of their registers? and If I want to choose another micro from other companies, I should learn all of their registers too from the first?

You firstly need to know the main registers, usually related to Timers, Watchdog, Pinout, etc...
As you start managing the builtin peripherals, you'll need to know them, of course.
 
There are a lot of configuration assistance tools available.
For example, initialising SPI on STM32F103 with SPL:
Code:
void Init_SPI1 (void)
{
	GPIO_InitTypeDef GPIO_InitStruct;
	SPI_InitTypeDef SPI_InitStruct;
	
	GPIO_InitStruct.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_5;		 
	GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP;
	GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_Init(GPIOB, &GPIO_InitStruct);

	GPIO_InitStruct.GPIO_Pin = GPIO_Pin_4;
	GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IPU;
	GPIO_Init(GPIOB, &GPIO_InitStruct);
	
	SPI_InitStruct.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
	SPI_InitStruct.SPI_Mode = SPI_Mode_Master;
	SPI_InitStruct.SPI_DataSize = SPI_DataSize_8b;
	SPI_InitStruct.SPI_CPOL = SPI_CPOL_Low;
	SPI_InitStruct.SPI_CPHA = SPI_CPHA_1Edge;
	SPI_InitStruct.SPI_NSS = SPI_NSS_Soft;
	SPI_InitStruct.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_256;
	SPI_InitStruct.SPI_FirstBit = SPI_FirstBit_MSB;
	SPI_InitStruct.SPI_CRCPolynomial = 7;
	SPI_Init(SPI1, &SPI_InitStruct);

	SPI_CalculateCRC(SPI1, DISABLE);
	SPI_Cmd(SPI1, ENABLE);
}
Have you seen any registers here?
 
Kind of like having a road map.
You don't need to learn all of it, just look up the details of the part between where you are and where you want to go.

With the software users manual, you then look up the section you are interested in, like how to set up for serial input/output for instance.
There you will probably find several registers, and the book will explain what each bit in each register does.

It can be really difficult to get started with an unfamiliar chip, it can (for me) sometimes take a day or two to get it to do what I want it to do.

But like finding your way around in an unfamiliar city, you quickly learn, and once you have initialised some of the registers and actually get parts of the system up and working, it all starts to become much clearer.

Its getting started that can be really frustrating.
And all of us here have been through that.
 
Its getting started that can be really frustrating. .

So true. But once you start getting the feel of it, it also feels a strange happiness...

There can be no short-cuts but first thing first: you must know have the clear idea what can be potentially done and what are the tools that are available. So that you know...

Flip through the manual: the commercial success of a microcontroller depends on the quality of the documentation. That is the last place you will always look...
 

There are a lot of configuration assistance tools available.
For example, initialising SPI on STM32F103 with SPL:
Code:
void Init_SPI1 (void)
{
	GPIO_InitTypeDef GPIO_InitStruct;
	SPI_InitTypeDef SPI_InitStruct;
	
	GPIO_InitStruct.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_5;		 
	GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP;
	GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_Init(GPIOB, &GPIO_InitStruct);

	GPIO_InitStruct.GPIO_Pin = GPIO_Pin_4;
	GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IPU;
	GPIO_Init(GPIOB, &GPIO_InitStruct);
	
	SPI_InitStruct.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
	SPI_InitStruct.SPI_Mode = SPI_Mode_Master;
	SPI_InitStruct.SPI_DataSize = SPI_DataSize_8b;
	SPI_InitStruct.SPI_CPOL = SPI_CPOL_Low;
	SPI_InitStruct.SPI_CPHA = SPI_CPHA_1Edge;
	SPI_InitStruct.SPI_NSS = SPI_NSS_Soft;
	SPI_InitStruct.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_256;
	SPI_InitStruct.SPI_FirstBit = SPI_FirstBit_MSB;
	SPI_InitStruct.SPI_CRCPolynomial = 7;
	SPI_Init(SPI1, &SPI_InitStruct);

	SPI_CalculateCRC(SPI1, DISABLE);
	SPI_Cmd(SPI1, ENABLE);
}
Have you seen any registers here?


What is this?
Is this CMSIS library?
 

Well, you need to learn about the registers or the libraries. Depends on the language environment you are programming. Take your pick.

Personally I feel that knowing the basic architecture of the microprocessor is helpful. You can always search for libraries and look up the microprocessor documentation.

Good documentation for the libraries is rare.
 

Hi,

I agree.

There´s no need to know each bit and it´s function. But I recommend to read through all of the datasheet to get a clue about it´s perifierals and features.

Often - if you don´t know about your microcontroller - you may use more difficult and less effective solutions than when you properly use the built in periferals.


Klaus
 
  • Like
Reactions: Alloy

    Alloy

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top