EmbeddedRelated.com

Eric (@tcfkat)

Hardware engineer, experience in board level development of analog/digital electronics, MCU programming in C/Assembler. Documenting in LaTeX. Currently working as Teacher for Electronics. Located in Belgium (UTC+1/+2), mother tongue German.

Brainf*ck in C

New thread started 4 weeks ago
No, I do not want to insult you.Yes, this has rather nothing to do with embedded.Brainfuck is a so called esoteric programming language, created by the Swiss Urban...

Re: SD card logging in STM32 Microcontroller

Reply posted 3 months ago (01/31/2024)
1) Can you show the whole code? How many times your function is called?2) How big is your buffer? With:f_write(&file, buffer, sizeof(buffer), NULL);you write...

Re: [ESP32] [ESPIDF] Simoultaneous interrupt handling

Reply posted 7 months ago (09/08/2023)
void actbutt0(void); // prototypes of functionsvoid actbutt1(void); // if button is pressedvoid actbutt2(void);void actbutt3(void); // ... and so on ... till actbutt15//...

Re: Qualifying Crystal for MCU

Reply posted 8 months ago (08/18/2023)
Somewhere in the data sheet is stated that for BT max. +-10ppm deviation is allowed.Why no external load capacitors on the crystal? Any reason?As I assume that you...

Re: Qualifying Crystal for MCU

Reply posted 8 months ago (08/17/2023)
Did you respect the recommended layout guidelines?

Re: Help stop the Arduino compiler outwitting me

Reply posted 8 months ago (08/08/2023)
Maybe also interesting, if you move tstVal outside of the function RunTests() into global name space:struct TestTime_t TestTimes[NUM_TESTS];int tstVal;then the...

Re: Help stop the Arduino compiler outwitting me

Reply posted 8 months ago (08/08/2023)
Hello Max! Definitely the compiler optimizes out the whole loop! First please turn on all messages in f****ing Arduino: File --> Preferences --> Show verbose...

Re: MPS430 F_CPU undefined error on compilation

Reply posted 1 year ago (03/05/2023)
Hello Allan! As I have for a future project some MSP430 around here (more exactly MSP430F2013IN) I decided to install the IDE and compile your sample -- it compiles...

Re: Coding challenge in C for embedded systems

Reply posted 2 years ago (07/15/2022)
scnr ... /** * (C) tcfkat 2022 for embeddedrelated.com * NO PERMISSION TO USE EXCEPT FOR EDUCATIONAL USE */ #include <stdint.h> #include <math.h>...

Re: Coding challenge in C for embedded systems

Reply posted 2 years ago (07/13/2022)
Hello! 1) After all, who is applying, you, or the forum? This is your first post, what have you contributed to the forum? 2) There are number of beginner bugs...
Re Sriram,I would use optos only if I need the isolation barrier. Also, standard optos can be real slow, unless you use fast optos. (The thread starter says nothing...
Hello Sriram,these are not optos but Logic-Level MOSFETs which provide bidirectional level shifting as needed for I2C, based on Application Note AN97055 from Philips....
I would use resistors ... ;)

Re: Reading code from AT89C51ED2

Reply posted 2 years ago (02/15/2022)
Sorry, I was to fast and I was wrong. The above said is true for the AT89S52/AT89C52 only.This MCU can be in-circuit programmed using 5V only, if you respect the...

Re: Reading code from AT89C51ED2

Reply posted 2 years ago (02/14/2022)
Hello marco,the answer is simple: AT89C51 needs 12V Vpp (that your circuit does not provide) while AT89S51 can be programmed in-circuit with 5V only. Reading the...
Hello Elliott, yes, the autodetect routine is not necessary in your case. But, something in your I2C-code is totally wrong. You should be able to turn the backlight...
Hello Elliott, without digging to deep into your code ... your timing seems to be wrong. Afaik some of the HD44780 controller clones takes longer, especially...

Re: Determining the index of a value in a struct

Reply posted 3 years ago (08/05/2021)
Hi Max, why do you stick to the union construct? My suggestion (untested): #define EEROMOFF 0 #define SETTINGSSIZE 3 enum SettingsOffset { DateFormat = 0, TimeFormat,...

Re: Why CRC with EPROM?

Reply posted 3 years ago (06/25/2021)
With CRC you can: test: yes repair: no! You need redundancy to repair data ...
Apart from the fact that the values associated with "constant variables" can't be changed under program control, is there any other value to them (e.g., in terms...

Re: Why CRC with EPROM?

Reply posted 3 years ago (06/25/2021)
To overcome data corruption (due to cell wearing/power failure/whatever) you can write always sequentially two identically data sets. If, when reading, one CRC is...
Max, memcpy does not work with the EEPROM, this should be clear. The EEPROM needs its proper write routines. But you still don't need a union. You can copy byte...
Hello Max! 1) You don't need a union. To determine the size the sizeof()-operator is there. This is also more flexible and less error-prone than a static #define! 2)...

Re: Another Noddy Question

Reply posted 3 years ago (06/09/2021)
By the way, I found this interesting article about #pragma pack:Anybody who writes #pragma pack(1) may as well just wear a sign on their forehead that says “I...
This here: averageFloat = 100 - (sumM / 10 - 400) * 0.25641; //Calculation average moisture from array sum. Converting 0-1024 range to 0-100. Calibrate average...

Re: UART communication with ACK/NACK error handling

Reply posted 3 years ago (03/25/2021)
Ok, don't mind, meanwhile I saw your profile. Although most MCU will not be destroyed immediately by a short an outputs it is strongly deprecated to do this. Use...

Re: UART communication with ACK/NACK error handling

Reply posted 3 years ago (03/24/2021)
If the TX pin is configured as (totem-pole) output, as it should be, it is not a good idea to directly shorten that pin to GND or Vdd!You can however put a, say...

Re: UART communication with ACK/NACK error handling

Reply posted 3 years ago (03/24/2021)
If both MCU are hardwired you don't need pullups. After booting you must anyway clear all receiver buffers.Pullups should be used if the RX line can be left open.But,...

Re: UART communication with ACK/NACK error handling

Reply posted 3 years ago (03/24/2021)
Wondering about the pullup/pulldown-story, in the first post ... UART lines are active driven, i.e. totem-pole. Contrary to open-drain I2C.This on the TX MCU side:    TRISDbits.TRISD6...

Re: UART communication with ACK/NACK error handling

Reply posted 3 years ago (03/24/2021)
First, check the clocks! They don't need to be exactly the same, but as said not more than 5% different. For example, if the TX is to slow, the RX will sample a...

Re: UART communication with ACK/NACK error handling

Reply posted 3 years ago (03/24/2021)
Again, this does not work if the RX is dead, missing etc. In this case you must use a timeout or your system hangs forever.

Re: UART communication with ACK/NACK error handling

Reply posted 3 years ago (03/24/2021)
Ok, I missunderstood the function. But waiting forever on an answer is no good idea. If the link is broken this is a deadlock. You should work with timeouts.And,...

Re: UART communication with ACK/NACK error handling

Reply posted 3 years ago (03/23/2021)
I did not read all and everything ... 1) Declare all vars modified in ISR as volatile, so the compiler is forced to re-read them. Otherwhise re-reading may be omitted...
Afaik there are tools to do that. Or, are at least easy to write: removing all comments and whitespaces, rename all variables to cryptic random names, replace all...
Oh, thanks!But this is a simple bit-wise addition with a ripple-carry loop, nothing magic. Using digraphs and trigraphs, special variable names and removing all...
The "++++" is only in the string, this is symbolic for two increments ... it is not a valid C syntax.
Question 1: My suggestions (tested) #include <stdio.h>#include <stdint.h>void main(void){  uint8_t fred = 40;  uint8_t i, o;  printf("Fred: %u\n",...

Re: Anybody experienced in Advantech PCM 9373

Reply posted 4 years ago (08/01/2020)
1) As my mother tongue is German, I don't care about UK/US nomenclature ... ;)2) The color/colour of the pushbutton is of no importance. Maybe because the reset...

Re: Anybody experienced in Advantech PCM 9373

Reply posted 4 years ago (08/01/2020)
Don't rely to much on "replace the complete unit", chinese documentation often has to be interpreted.I suppose you already have reset the BIOS config? S2 seems to...

Re: Anybody experienced in Advantech PCM 9373

Reply posted 4 years ago (08/01/2020)
Hi,while not having experience with this specific board ... 15 pin is the normal pin-out of VGA, so, did you connect a VGA monitor to the DE15 connector? You should...

Re: Interface to program STM8 ?

Reply posted 4 years ago (06/16/2020)
Nope, SDCC (Version > 3.4; actual 4.0.2) supports STM8.stm8flash burns them, using the cheap ST-Link V2.Links:SDCC: http://sdcc.sourceforge.net/stm8flash: https://github.com/vdudouyt/stm8flashCode...

Use this form to contact tcfkat

Before you can contact a member of the *Related Sites:

  • You must be logged in (register here)
  • You must confirm you email address