Block Diagram for the Internal Resources of ATmega328P MCU

I’m still going with the data sheet . This is very clear and each box is broken down elsewhere . The pinout for the chips ( which are in different formats ) are also shown and relate directly to the ports etc .

Pictures for idea only, links to the actual data sheet are easily found ( sorry jpg police )

These serve very well to the Engineering people and not much useful for the fresh students who are just learning the architecture of ATmega328P MCU.

I think that for fresh students it is more important to learn about processors in general than any specific type. And for these students is essential to understand peripherials, as building blocks of a processor. OP still seems to think of them as 'alternate functions of I/O pins'. Yes, the I/O pins have alternate functions, but that is because bringing out the signals from the peripherials to separate pins would increase the number of pins dramatically.

OP still uses the term 'sequence generator' where 'instruction decoder' would be the proper term. In processors like 8080 and 8085, where one instruction takes 4 clock cycles or more to process, a sequence of states is necessary while in AVR processors there is no sequence to speak of.

Use of a building block 'result register' is more ambiguous, some processors do indeed contain such a register, often named 'accumulator'. AVR processors do not. However, the documentation of AVR does mention this term, not referring to a building block but as to address one of the working registers where the result must be stored.

Students (and others) that have a good understanding of processors in general will be able to read the datasheets like the ones referred to in this thread.

Thank you for the constructive comments from which I have gained better understanding particularly on why "Instruction Decoder (Fig-1 below)" instead of "Sequence Generator" would be an appropriate term for AVR which does not use (like 8085) multiple clock cycles to perform a read/write operation but a single cycle.

Note: Though AVR does not use multiple clock cycles (for read/write operation) and yet its single cycle has four states (Rising Edge, HIGH, Falling Edge, LOW) which, I believe, are utilized in a way similar to multiple clock cycles of 8085. This may be one reason for calling the AVR a RISC Machine and the 8085/8086 is a CISC Machine.


Figure-1:

Datasheet has also used the term "Alternate Function". When one function is active, the other function remains Off like A4/A5 of UNOR3 which will serve either as analog channels for the internal ADC Module or SDA/SCL lines for the internal I2C Module during the assigned time slot.

In that case, a teacher may present the architecture of 8085/8086 (Fig-2, 3) to see the roles of the Address Bus, Data Bus, Control Bus, Memory Interfacing, Instruction Fatching/Decoding, Operand Reading, and etc. What do you think?


Figure-2:


Fetch and Execution Mechanism of the instruction: add WORD PTR ds:[bx+1234h], 5678h
Figure-3:

Have you yet written any specimen exam questions for this course you are developing?
I'm curious to see if I would pas :slight_smile:

Yes! Here is one made at the very early time of teaching ATmega328P. After that for every year, I have prepared two question papers.

It is here:
AUST-Spring18-Final.pdf (506.7 KB)

The above text is presented below by a diagram (Fig-1):


Figure-1:

that takes over control of PPins (physical pin) 2 and 3 of MCU 0 and 1 of PORTD, if enabled to route the signals.

In Fig-1, (by default) PPin-2 of the MCU bears a digital signal (PD0) from Port-D. As a result, PPin-2 bears the signal signature PD0.

If programmer desires, PPin-2 can be used to convey RX0 signal from the USART0 Module and now PPin-2 will bear the signal signature RX0.

Now, I understand that RX0 is not the alternate function of PD0. As you have said that these two signals are independent and belongs to two seperate modules. They can be alternately routed to the external circuit over the single PPin-2.

The source of my confusion is the datasheet when it says "alternate functions".

(from datashet, P18, 2016)image


Figure-2:

In Fig-2, ADC4 and SDA are not the alternate functions of PC4; rather, they are independent functions. ADC4, SDA, and PC4 signals can be alternately routed to outside over the single PPin-27 of the MCU.

Yes, PC4, ADC4, SDA and PCINT12 are alternate functions of the same pin. The datasheet must mention them as such for the user to find them. Nevertheless, the peripherials PORT, ADC, I2C and InterruptController are physical building blocks within the chip.

You might ponder about ADC6, ADC7 and alternative functions.

Fig-1 is a coceptual diagram that sows how PC4, ADC4, SDA, PCINT12 signals can be alternately routed over the single PPin-27 of MCU. These signals are not the alternate functions of PPin-27; rather, they each belong to independent processing modules as is shown in Fig-1.


`Figure-1:

1. To route only PC4/PC5 signal over PPin-27/28, we include the following codes in the sketch. As a result, only S1 switch of Fig-1 gets closed; S2 - S4 remain opened.

pinMode(A4, OUTPUT);
pinMode(A5, OUTPUT);

2. To acquire only ADC4/ADC5 signals over PPin-27/28, we include the following codes in the sketch. As a result, only S2 switch of Fig-1 gets closed; S1, S3, S4 remain opened.

ADCSRA(ADEN, HIGH);

3. To route only I2C signal over PPin-27/28, we include the following codes in the sketch. As a result, only S3 switch of Fig-1 gets closed; S1, S2, S4 remain opened.

#include<Wire.h>
Wire.begin();

4. To acquire external pin's logic level change interrupt signals over PPin-27/28, we include the following codes in the sketch. As a result, only S4 switch of Fig-1 gets closed; S1 - S3 remain opened.

 pinMode(A4, INPUT_PULLUP);//PPin-27 is input line with Rip
 PCMSK1(PCINT12, HIGH); 
 PCICR(PCIE1, HIGH); 
 interrupts();

This is the time to establish the definition of Alternate Function (if any) -- PC4, ADC4, SDA, and PCINT12 have no alternate functions; PPin-27 of the MCU is alternately (not multiplexing) conveying the signals PC4, ADC4, SDA, and PCINT12 on programmer's demand.

I have been delivering the Block Diagram to the students at my understanding level; now, I see that my understanding is full of many misconceptions which are being cleared up slowly from the comments of the posters of this thread.

Hmmmm I still have a few issues here .

Realistically , when they graduate I doubt if any students will use the Atmega 328 chip , so I don’t see the point of such great detail and , from the questions, memorising parts of the internal structure .

They will be using more up to date processors and different design methods using AI and so on .
Generic ideas on how processors work , machine code , 1’s and 0’ how registers set parameters , I/O circuit design give as good background .

I’ve never studied how the 328 works in details , if I want to something I’ll look at how that part , registers or whatever works , or find some similar project ( there are also application sheets from manufacturers )
I’m now using ESP32 type products and finding my way around in the same way .

Microchip already have marked the 328 as “ not suitable for new designs “ so it’s near end of life .
Here

Hence my finding stuff in data sheets is more useful and applicable to other chips .:french_fries: I’d like to see questions on designing stuff with the data sheet supplied .”

School/Unversity still teaches 7400 Logic -- why?

Education is different from Technology.

Moreover, Arduino Forum is primarily oriented with ATmega328 Microcontroller. So, learning about the internal structures/modules of the said MCU is useful and will help to explore architecture of ESP32 easily.

Higher achitecture like ESP32 are for business houses to develop cost effective products using SoC devices. How good ESP32 architecture is for learning the fundamentals of MCU?

Forum members are using these new fangled ESP32 now and are the processor type your students will use in their jobs , they may well be questioned on them in
interviews .
Fundamentals yes , I’d say the 328
Is too advanced for the basics - get hold of a z80 manual and see how that works at bit level ( the manuals are very detailed and give great insight into how stuff is clocked in and out etc ), then move onto “new” stuff

.Esp32

z80

Logic gates

I think the interviewers mainly focus on the attitude of the candidate if he can be trained in any new field which he never came across.

ch-18 ESP32Lec.pdf (1.1 MB)

It is quite challenging! Are the students allowed to use the ATmega328P datasheet and the Arduino reference documents during the exams? If not it is also a test of the student's memory instead of a test of pure understanding.

Anyway, when I look back at the stuff I had to learn to get a degree it is no different in that a lot is simply to test the student's ability to learn something even if it is of little or no practical value in later life.

I wouldn’t be quite that harsh , although most of the stuff I learnt I’ve never used - shouldn’t be that way .
Anyhow a lot of education is about how to find things out , how to learn new stuff .

Now where is that book on Fourier transforms and aerial design , aah next to the one on rotating machine design..,:rofl:

It is not an open book exam. However, as the Class Teacher himself is the examiner, any answer (partial/full) close to the correct answer is a proof that the student attended the class (s) and he is rated good.

Real life is an open book exam

Those books can be found in the Personal/Public Library. Now-a-days, almost everything is on the net and AI finds them in a moment. Who knows who will be living in this world after hundreds years later -- Machine or Man?

They are pristine books I have in my cupboard lol