Author Topic: Arduino serial monitor, From this forum because, I need an intelligent answer  (Read 6619 times)

0 Members and 1 Guest are viewing this topic.

Offline technix

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
For the Arduino sketch system, it is kind of a mini-RTOS with its own, semi-standardized hardware abstraction. The sketch is actually based on C++, and the build tool includes a preprocessor that can extract the usual project settings from the sketch file. Arduino implemented a layer of hardware abstraction to mask both the hardware implementation details (a set of drivers with standardized API) and the board differences (the same physical connector can map to different port/pin on different board and chip.) The RTOS part comes in either a dumbed-down FreeRTOS or Arduino's own preemptive context switching, as well as a good selection of guides on writing cooperative multitasking code.
 

Offline cstratton

  • Regular Contributor
  • *
  • Posts: 62
  • Country: us
it is kind of a mini-RTOS

No, it isn't.  Not even remotely.

Having interrupt based serial buffers and a timer interrupt does not constitute an RTOS or even cooperative multitasking.

 

Offline sokoloff

  • Super Contributor
  • ***
  • Posts: 1799
  • Country: us
it is kind of a mini-RTOS
No, it isn't.  Not even remotely.

Having interrupt based serial buffers and a timer interrupt does not constitute an RTOS or even cooperative multitasking.
Though it isn't on the AVR implementation, it is on the ESP32 Arduino implementation.

https://github.com/espressif/arduino-esp32

Whether that's really Arduino or not is perhaps of some debate.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
I find it vaguely amusing that the people who complain loudest about the inefficiency of "digitalWrite()" vs "PORTB |= 1" usually have a particularly poor understanding of the differences between the two...
 
The following users thanked this post: mtdoc, brucehoult, Naguissa

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4028
  • Country: nz
It's not crippling.. just another set of tools. Let's define what the Arduino is:

- A range of boards to choose from. Some may use the ATMEGA328, some don't. But above all, they are standardized on pin maps.
- The micros have a bootloader integrated, most of them are serial.
- You can upload programs via the Arduino IDE, or commandline tools.
- Sketches are preprocessed C++  programs. They include a few libraries:
   - Millisecond time base
   - Basic serial library, with asynchronous data receive (interrupts)
   - Functions for GPIOs, PWM and ADCs
   - A gazillion number of user libraries, of varying quality
   - A setup() and loop() convention, which is basically:

And if you want to automate things on a time scale of milliseconds or longer -- which is almost unimaginably quickly for the people Arduinos are aimed at -- then the fact that digitalWrite() takes a few us while you could bit-bang the actual register in a fraction of a us is of absolutely no importance whatsoever.

And if by some chance it's not fast enough on a 16 MHz 8 bit AVR then go and buy a 32 bit 80 MHz ARM-based board, or a 256 MHz RISC-V HiFive1. Your code will probably work as-is, zero changes, and any shields will plug right in also.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf