Author Topic: Want advice on learning programing language for electronics C or JAVA or Python  (Read 4464 times)

0 Members and 1 Guest are viewing this topic.

Offline SarvesaaTopic starter

  • Contributor
  • Posts: 36
  • Country: in
Dear friends,

I am going to join college to become an EE engineer. I have few weeks of time, so I am interested in learning a programing language.
I know some basic concepts of JAVA  from my schooling. Apart from that I want to learn many.

I want your advices in choosing a language whether C or JAVA or Python, which will be helpful in programing microcontrollers.

Thank you

With Regards
Sarvesaa Jagan
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 21226
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Dear friends,

I am going to join college to become an EE engineer. I have few weeks of time, so I am interested in learning a programing language.
I know some basic concepts of JAVA  from my schooling. Apart from that I want to learn many.

I want your advices in choosing a language whether C or JAVA or Python, which will be helpful in programing microcontrollers.

Thank you

With Regards
Sarvesaa Jagan

For embedded projects, C is the traditional choice - but under some circumstances Python is becoming an option.

You will not learn C (or another language) in a few weeks.

It is worth learning the basic principles/concepts of many languages, so you know which ones won't be appropriate for a given task, and which ones are more-or-less alike.
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 
The following users thanked this post: Sarvesaa

Offline Miyuki

  • Frequent Contributor
  • **
  • Posts: 908
  • Country: cz
    • Me on youtube
Almost all programming languages have common ancestry and are more like a dialect than different languages

Programming concepts, algorithmization, and other stuff are what matters and it is common for most of today's languages

And plain C is a good starting point to learn and works everywhere
« Last Edit: August 02, 2022, 03:01:08 pm by Miyuki »
 
The following users thanked this post: Sarvesaa

Offline radar_macgyver

  • Frequent Contributor
  • **
  • Posts: 748
  • Country: us
Stick with C for embedded stuff. If you've used Java, C syntax will look familiar, but you will have to 'unlearn' some stuff like how C deals with strings.
One of the better Youtube channels on programming in general (with a focus on C) is from Jacob Sorber:
https://www.youtube.com/c/JacobSorber
He's got some playlists made up, including one for C beginners. I would also suggest actually typing in the code (don't download it), running it, then start modifying it to do other things. Just watching the videos will not get you far.
 
The following users thanked this post: Sarvesaa

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 13216
Learn C, as ~95% of microcontroller based embedded systems are programmed in C or a C like subset of C++, but do try to pick up some Python as well as you often need something to script communication with your embedded gadget, running on a host with a full OS.

Even if all you do is get yourself an Arduino starter kit and try writing your own code for it (Arduino uses a C-like subset of GCC C++), you'll be a large step ahead of fellow students who haven't got any C programming experience.
 
The following users thanked this post: Sarvesaa

Offline tom66

  • Super Contributor
  • ***
  • Posts: 7334
  • Country: gb
  • Electronics Hobbyist & FPGA/Embedded Systems EE
Avoid Java at all costs and you will be much happier in your life (and so will anyone who deals with your code.)

Python is a great starter language.  C has quite the brick wall to it in terms of getting complex things working like data management.  So I recommend you start with Python to grasp the concepts of programming, then graduate to C on an Arduino or some similar platform.
 
The following users thanked this post: Sarvesaa

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9964
  • Country: us
What do you expect to use general purpose programming for during your time in college?  I would suggest learning Fortran because it is more useful for math kinds of things - but it won't be a popular recommendation and it still might not address the need to draw charts and graphs.

Next I would recommend Python because there are libraries for just about everything you can imagine.  C, although the most important, would be a distant 3rd place.  You will have to learn it anyway but the question is what comes first.

I suspect you will want to use a programming language to augment or simulate your course work.  I did it with Fortran back in '70 and '71 and used the attached plotter to get charts and graphs.  Charts and graphs on a step-by-step plotter are a lot of work.

Today, I would suggest getting very close to MATLAB.  At some universities, the program is free to students registered in certain programs and EE would certainly be one of them.  If you can't get MATLAB for free and you don't want to pay for the Home license, you can use GNU Octave for all of the math/plot work you will ever want to do.  I use both regularly even though I retired nearly 19 years ago.  At the university my grandson attended, there is a required MATLAB course for incoming freshman and the program will be used extensively throughout any STEM majors.  All of the math is done on MATLAB!  Well, except for some elementary math classes where pencil and paper are still required.

I really believe you should focus on MATLAB/Octave, particularly those examples that result in plots.

Get a MATLAB book and get started.  Amazon also has books on GNU Octave (and a lot on MATLAB) so pick one and get started.

Here is a little matrix algebra problem that you WILL run into, in some form, in one of your early math classes:

Code: [Select]
% A football stadium has a capacity of 100,000 attendees
% Ticket prices:
% Student  = $25
% Alumni   = $40
% Faculty  = $60
% Public   = $70
% Veterans = $32
% Guests   = $ 0
% A full capacity game netted $4,987,000
% Let S = number of students, A = number of alumni,   F = number of faculty
%     P = number of public,   V = number of veterans, G = number of guests

%      S  A  F  P   V  G =   value
M = [  1  1  1  1   1  1    100000; ... % total number of attendees
      25 40 60 70  32  0   4897000; ... % total revenue
       0  1 -1  0   0  0     11000; ... % 11000 more alumni than faculty
       0  1  0  1 -10  0         0; ... % public +  alumni = 10 * veterans
      -1  1  1  0   0  0         0; ... % alumni + faculty = students
       1  0  1  0  -4 -4         0];    % faculty + students = 4 (guests + veterans)
A = M(:,1:6); % extract 6x6 matrix
B = M(:,7);   % extract value column vector
P = M(2,1:6); % ticket price by attendee type
R = inv(A)*B; % compute number of attendees by type
T = sum(R);   % check total attendees = 100,000 CHECK
U = P*R;      % total revenue = 4,897,000 CHECK
V = R'.*P;    % revenue by attendee type - transpose R from 6x1 to 1x6
              % then do element by element multiplication
%
% fancy output, all previous default output semicoloned
%
label = {'Students' 'Alumni' 'Faculty' 'Public' 'Veterans' 'Guests'};
for i = 1:6
    printf('%-8s%7d @ %2d = %7d\n',label{i},...
                                   round(R(i)),...
                                   M(2,i),...
                                   round(V(i)))
end
printf('\nTotals   %6d       %8d\n',round(T), round(U))

% Results edited back into source code

%  Students  25000 @ 25 =  625000
%  Alumni    18000 @ 40 =  720000
%  Faculty    7000 @ 60 =  420000
%  Public    42000 @ 70 = 2940000
%  Veterans   6000 @ 32 =  192000
%  Guests     2000 @  0 =       0

%  Totals   100000        4897000


We know the total revenue and the total headcount and some relations between various categories.  We put it all in a matrix and do some magic matrix inversion, transpose and multiply to get the number of attendees in each category.  This is a very elementary intro to matrix algebra but the concept will show up all over the place when you get to Kirchhoff's equations and nodal/mesh analysis.

Note how we specify 11,000 more alumni than faculty.  Number of alumni minus number of faculty = 11,000.  This is where the magic happens, creating the matrix with all the conditions.

Look at how easy it is to strip a column off the matrix and call it a new vector.  MATLAB -> MATrix LABratory

Here's an RC charge and discharge plot:

Code: [Select]
V0 = 1; % assume a supply voltage
R = 10000; %10k Ohms
C = 0.1*10^-6; % 0.1 ufd
Tau = R*C;
t = linspace(0,8*Tau);
Vchg = V0 * (1 - exp((-t/Tau)));
Vdis = V0 * (exp((-t/Tau)));
plot(t, Vchg)
grid minor
grid on
hold on
plot(t,Vdis)
ylabel("Voltage")
xlabel("Time - seconds")
%there is a known bug in 'legend', the [h,~] is a kludge to work around it
[h,~]=legend("Charge Voltage","Discharge Voltage");
figure(gcf) % or shg command - pull plot to top
for Tau = 0:6
    pct_charge = V0 * (1 - exp((-Tau))); %percent charge
    t1 = -log((1-pct_charge)); % my version
    t2 = log(1/(1-pct_charge));% book version
    fprintf("%% Tau = %.0f Percent Charge = %5.2f,\t t1 = %7.3f, t2 = %7.3f\n", ...
            Tau, 100*pct_charge,t1,t2)
end

% output

% Tau = 0 Percent Charge =  0.00, t1 =  -0.000, t2 =   0.000
% Tau = 1 Percent Charge = 63.21, t1 =   1.000, t2 =   1.000
% Tau = 2 Percent Charge = 86.47, t1 =   2.000, t2 =   2.000
% Tau = 3 Percent Charge = 95.02, t1 =   3.000, t2 =   3.000
% Tau = 4 Percent Charge = 98.17, t1 =   4.000, t2 =   4.000
% Tau = 5 Percent Charge = 99.33, t1 =   5.000, t2 =   5.000
% Tau = 6 Percent Charge = 99.75, t1 =   6.000, t2 =   6.000

Both of these examples run in the free version of Octave as well as under MATLAB

Hint:  Octave will accept # as starting a comment, MATLAB won't.  Both will accept % so that is what I use.  I never know which program I will be using because MATLAB is only licensed on one machine but Octave runs everywhere.  MATLAB has many add-on packages that Octave simply doesn't have - Simulink being very important later on.  Others like the EE package are also important and if you can swing MATLAB and the extra cost packages, do it.  Otherwise, Octave will have to do.

Don't forget Desmos.com for graphing and Symbolab.com for solving.


« Last Edit: August 02, 2022, 05:16:58 pm by rstofer »
 
The following users thanked this post: Sarvesaa

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 21226
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Almost all programming languages have common ancestry and are more like a dialect than different languages

I presume you mean the languages derived from COBOL, Fortran, Algol, Basic, APL, LISP, Forth and Prolog.

You should also include statistical languages (e.g. R) and the various FSM specification languages (e.g. Harel StateCharts).

Quote
Programming concepts, algorithmization, and other stuff are what matters and it is common for most of today's languages

And plain C is a good starting point to learn and works everywhere

Knowing which specification technique to use is essential. It is stupid to try to use FSM specification techniques for a statistical problem, etc.
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 
The following users thanked this post: Sarvesaa

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9964
  • Country: us
You should also include statistical languages (e.g. R)

With all the emphasis on big data, languages like R are essential.  MATLAB also plays in this arena:

https://www.mathworks.com/solutions/big-data-matlab.html

If it involves numbers, MATLAB is all over it!  Excel also has a lot of capability that is seldom used.
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15797
  • Country: fr
Both C and Python will be useful for an EE. (I don't like Python much myself, but it's almost impossible to ignore these days especially if you're a young engineer.)

Java, not at all.
 
The following users thanked this post: ebastler

Online coppice

  • Super Contributor
  • ***
  • Posts: 10034
  • Country: gb
You will not learn C (or another language) in a few weeks.
What you won't learn quickly is how to program well. If you have years of years of programming behind you, you should be able to get useful in a new language in a week.
 
The following users thanked this post: Sarvesaa

Online coppice

  • Super Contributor
  • ***
  • Posts: 10034
  • Country: gb
Most university courses teach you python these days. For small embedded systems (e.g. MCUs) C is the main language. For bigger systems a wide diversity of languages are used.
 
The following users thanked this post: Sarvesaa

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9964
  • Country: us
A few years ago, our moderator (Simon) posted a Kirchhoff mesh type problem with reactive components which leads immediately to complex numbers.  The wxMaxima solution is:

Code: [Select]
 -->	ratprint    : false$
fpprintprec : 4$

eq1  :   0 = -V1 + Z1*I1 + Z4*(I1-I2) ;
eq2  :   0 = Z4*(I2-I1) + Z2*(I2-I4) + Z5*(I2-I3) ;
eq3  :   0 = Z5*(I3-I2) + Z3*I3 + V2 ;
eq4  :   0 = Z2*(I4-I2) + V3 ;
eq5  :   VA = V1 - I1*Z1 ;
eq6  :   VB = VA - V3 ;
eq7  :   Z1 = 2 ;
eq8  :   Z2 = -5*%i ;
eq9  :   Z3 = 4 ;
eq10 :   Z4 = -5*%i ;
eq11 :   Z5 = 4*%i ;
eq12 :   V1 = 120 ;
eq13 :   V2 = 120*%i ;
eq14 :   V3 = 14.14*%i + 14.14 ;

res  : solve([eq1,eq2,eq3,eq4,eq5,eq6,eq7,eq8,eq9,eq10,eq11,eq12,eq13,eq14])$

results : expand(float(res))$
lngth   : length(results[1])$
sorted  : sort(results[1])$

print("")$
for i:1 thru lngth do
    print(sorted[i])$

(eq1) 0=(I1-I2)*Z4+I1*Z1-V1
(eq2) 0=(I2-I3)*Z5+(I2-I1)*Z4+(I2-I4)*Z2
(eq3) 0=(I3-I2)*Z5+I3*Z3+V2
(eq4) 0=(I4-I2)*Z2+V3
(eq5) VA=V1-I1*Z1
(eq6) VB=VA-V3
(eq7) Z1=2
(eq8) Z2=-5*%i
(eq9) Z3=4
(eq10) Z4=-5*%i
(eq11) Z5=4*%i
(eq12) V1=120
(eq13) V2=120*%i
(eq14) V3=14.14*%i+14.14

/* RESULTS */

I1=16.81-22.88*%i
I2=25.96-40.15*%i
I3=18.06-22.1*%i
I4=28.79-42.98*%i
V1=120.0
V2=120.0*%i
V3=14.14*%i+14.14
VA=45.76*%i+86.38
VB=31.62*%i+72.24
Z1=2.0
Z2=-5.0*%i
Z3=4.0
Z4=-5.0*%i
Z5=4.0*%i
Maxima is very popular at CERN and wxMaxima simply adds a GUI IDE.  Definitely worth knowing.  Amazon has a Kindle book for wxMaxima, also in paperback but the Maxima books seem to be in Spanish.

Note how we just create a bunch of equations and then stuff them all into the solve() function.  Pretty slick considering the number of complex values.

Here is the MATLAB code for the same problem, it needs a little rework before it will run on Octave:

Code: [Select]
format = '%s %6.3f %+6.3fj  :: %6.3f@%+6.3f Degrees\n';

z1 = 2;
z2 = -5j;
z3 = 4;
z4 = -5j;
z5 = 4j;
v1 = 120;
v2 = 120j;
v3 = 14.14 + 14.14j;

syms i1 i2 i3 i4

eqn1  = -v1 + z1 * i1 + z4 * (i1 - i2) == 0;
eqn2  = z4 * (i2 - i1) + z2 * (i2 - i4) + z5 * (i2 - i3) == 0;
eqn3  = z5 * (i3 - i2) + z3 * i3 + v2 == 0;
eqn4  = z2 * (i4 - i2) + v3 == 0;

[A,B] = equationsToMatrix([eqn1,eqn2,eqn3,eqn4],[i1,i2,i3,i4]);
X = linsolve(A,B);

va     = v1 - z1 * X(1);
vb     = va - v3;

rx1    = real(X(1));
ix1    = imag(X(1));
theta1 = rad2deg(double(angle(X(1))));
mag1   = abs(X(1));

rx2    = real(X(2));
ix2    = imag(X(2));
theta2 = rad2deg(double(angle(X(2))));
mag2   = abs(X(2));

rx3    = real(X(3));
ix3    = imag(X(3));
theta3 = rad2deg(double(angle(X(3))));
mag3   = abs(X(3));

rx4    = real(X(4));
ix4    = imag(X(4));
theta4 = rad2deg(double(angle(X(4))));
mag4   = abs(X(4));

rxa    = real(va);
ixa    = imag(va);
maga   = abs(va);
thetaa = rad2deg(double(angle(va)));

rxb    = real(vb);
ixb    = imag(vb);
magb   = abs(vb);
thetab = rad2deg(double(angle(vb)));

fprintf(format,'i1:',rx1,ix1,mag1,theta1, ...
               'i2:',rx2,ix2,mag2,theta2, ...
               'i3:',rx3,ix3,mag3,theta3, ...
               'i4:',rx4,ix4,mag4,theta4, ...
               'va:',rxa,ixa,maga,thetaa, ...
               'vb:',rxb,ixb,magb,thetab);

And the MATLAB results:
Code: [Select]
>> MeshAnalysis
i1: 16.812 -22.879j  :: 28.392@-53.691 Degrees
i2: 25.964 -40.154j  :: 47.817@-57.114 Degrees
i3: 18.059 -22.095j  :: 28.537@-50.740 Degrees
i4: 28.792 -42.982j  :: 51.734@-56.184 Degrees
va: 86.376 +45.758j  :: 97.748@+27.913 Degrees
vb: 72.236 +31.618j  :: 78.853@+23.639 Degrees

There are a number of languages more immediately applicable to EE than C and almost everything is more applicable than Java.
« Last Edit: August 02, 2022, 07:39:03 pm by rstofer »
 
The following users thanked this post: Sarvesaa

Online nctnico

  • Super Contributor
  • ***
  • Posts: 28429
  • Country: nl
    • NCT Developments
You will not learn C (or another language) in a few weeks.
What you won't learn quickly is how to program well. If you have years of years of programming behind you, you should be able to get useful in a new language in a week.
I disagree. A programming language is much more than the language itself. You also need to learn how the use the libraries / modules that come with a language in order to use a programming language effectively. This can be a huge learning curve by itself.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Online coppice

  • Super Contributor
  • ***
  • Posts: 10034
  • Country: gb
You will not learn C (or another language) in a few weeks.
What you won't learn quickly is how to program well. If you have years of years of programming behind you, you should be able to get useful in a new language in a week.
I disagree. A programming language is much more than the language itself. You also need to learn how the use the libraries / modules that come with a language in order to use a programming language effectively. This can be a huge learning curve by itself.
I said you can be useful. Not an expert.
 

Offline emece67

  • Frequent Contributor
  • **
  • !
  • Posts: 614
  • Country: 00
« Last Edit: August 19, 2022, 05:43:57 pm by emece67 »
 
The following users thanked this post: Sarvesaa

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9964
  • Country: us
MicroPython for certain uCs is quite handy.  It clearly works well on the Raspberry Pi Pico and Pico W.  It is clearly worth the time to learn Python.

All of my postings in this thread are oriented toward tools used for learning, not necessarily commercial projects.  Those will have a language choice made by an out-of-touch manager and cast in stone regardless of facts.
 
The following users thanked this post: Sarvesaa

Offline makingdevices

  • Newbie
  • Posts: 4
  • Country: es
C is the way to go for embedded systems, there is no discussion there... However, I can relate that uPython and Python itself are quite useful and handy for fast-prototyping and Tasks automation. Indeed, I am starting to see some "internal" projects done in micropython and raspberry pis in both Solar and EV industry... Quite interesting. All in all, it is known that C has a x100 factor over python in speed, so C is the winner when you need to sell to a client a robust/fast product.
 
The following users thanked this post: Sarvesaa

Offline SarvesaaTopic starter

  • Contributor
  • Posts: 36
  • Country: in
I have been studying and coding in JAVA from 9th grade to 12th grade as a part of school syllabus.
I did many programs that include fundamentals.For example
Scanner classes, Buffered readers, iterations, strings, arrays 2Dimensional 3Dimensional.
So I think C and other languages will be easy to learn.
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 20360
  • Country: gb
  • 0999
C is definitely the way to go for microcontrollers. Optimised compilers produce fast and light code and it's good for low level stuff such as accessing memory directly.

It's still good to familiarise yourself with assembly. I know it's not as important as it used to be, but it's still a good idea to know what's going on at a lower level.
 
The following users thanked this post: Sarvesaa

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 21226
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
I have been studying and coding in JAVA from 9th grade to 12th grade as a part of school syllabus.
I did many programs that include fundamentals.For example
Scanner classes, Buffered readers, iterations, strings, arrays 2Dimensional 3Dimensional.
So I think C and other languages will be easy to learn.

Regrettably that is no longer the case. Arguably it hasn't been the case since the early 90s.

I presume that by "learn" you mean more than "no compilation errors".

The subtle details of what the language does not guarantee are problem for both the beginner and the experienced developer. Evidence:
  • the existence of "language lawyers" that enjoy endlessly debating what a construct means and doesn't mean
  • that increasing the level of compiler optimisation frequently changes the program's behaviour. When that happens it is defined to be "programmer error", which is the programming equivalent of "blaming the victim"
  • the Linux kernel uses only -O2 optimisation, and -O4 optimisation is frequently forbidden by Torvalds. Make sure you understand why!
  • what you can and can't guarantee depends on which version of the language you are using
  • until recently it was impossible to implement threads as a C library.[1] Think about that. Many professionals didn't believe it, let alone understand it!

[1] http://hboehm.info/misc_slides/pldi05_threads.pdf http://www.hpl.hp.com/techreports/2004/HPL-2004-209.pdf
« Last Edit: August 03, 2022, 11:52:27 am by tggzzz »
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 
The following users thanked this post: Sarvesaa

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 21226
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
C is definitely the way to go for microcontrollers. Optimised compilers produce fast and light code and it's good for low level stuff such as accessing memory directly.

It's still good to familiarise yourself with assembly. I know it's not as important as it used to be, but it's still a good idea to know what's going on at a lower level.

See my previous post :(

Being able to read assembler is vital for embedded programming:
  • when debugging
  • when figuring out WTF the compiler has done now
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 
The following users thanked this post: tom66, Ian.M, Sarvesaa

Online Zero999

  • Super Contributor
  • ***
  • Posts: 20360
  • Country: gb
  • 0999
C is definitely the way to go for microcontrollers. Optimised compilers produce fast and light code and it's good for low level stuff such as accessing memory directly.

It's still good to familiarise yourself with assembly. I know it's not as important as it used to be, but it's still a good idea to know what's going on at a lower level.

See my previous post :(

Being able to read assembler is vital for embedded programming:
  • when debugging
  • when figuring out WTF the compiler has done now
Which post?

Did you ever post over on  Electro-Tech-Online? There was a moderator who would insist every beginner to microcontrollers should start with PICs and use assembly, not C, or any better architecture.  :palm:

Anyway, I got banned from there long ago, because a different moderator was too PC. He'd blame me and others for telling lazy students who signed up to get their homework done for them to bugger off.

I agree, it's good to know assembly language, but it's not worth using it to write entire programs in any more.
« Last Edit: August 03, 2022, 01:28:02 pm by Zero999 »
 
The following users thanked this post: Sarvesaa

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 21226
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
C is definitely the way to go for microcontrollers. Optimised compilers produce fast and light code and it's good for low level stuff such as accessing memory directly.

It's still good to familiarise yourself with assembly. I know it's not as important as it used to be, but it's still a good idea to know what's going on at a lower level.

See my previous post :(

Being able to read assembler is vital for embedded programming:
  • when debugging
  • when figuring out WTF the compiler has done now
Which post?

My post was #21. My previous post was #20 :)

Quote
Did you ever post over on  [urkl=https://www.electro-tech-online.com/]Electro-Tech-Online[/url]? There was a moderator who would insist every beginner to microcontrollers should start with PICs and use assembly, not C, or any better architecture.  :palm:

Anyway, I got banned from there long ago, because a different moderator was too PC. He'd blame me and others for telling lazy students who signed up to get their homework done for them to bugger off.

Never heard of it.

That mod sounds like a twat that insists "ontogeny recapitulates phylogeny".

Quote
I agree, it's good to know assembly language, but it's not worth using it to write entire programs in any more.

Yup :)

Except for a trivial non-preemptive task scheduler which does little more than save/restore the condition codes, SP and PC :)
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 
The following users thanked this post: Sarvesaa

Offline tom66

  • Super Contributor
  • ***
  • Posts: 7334
  • Country: gb
  • Electronics Hobbyist & FPGA/Embedded Systems EE
Being able to read assembler is vital for embedded programming:
  • when debugging
  • when figuring out WTF the compiler has done now

Add to it: when figuring out bugs in slightly obscure compilers... more so than just seeing implementation variations (where the compiler produces compliant but unexpected code.)

GCC is pretty bug free (in my experience) but I've found at least three code-breaking bugs in Microchip's XC8.

One fun one was that structures with more than 128 bytes size were not handled correctly on PIC18 because the offset-from-pointer instruction/register expected a signed 8 bit integer, but the compiler was treating this as an unsigned 8 bit integer.  Seeing the disassembly suddenly wrap around for high order members to negative pointer offsets was rather telling.
 
The following users thanked this post: Sarvesaa


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf