1
\$\begingroup\$

I want to learn about microcontrollers and use them in some projects. But I do not want to buy an Arduino, although that is what would be easy for doing projects. This creates a problem in programming the microcontroller. Although a programmer can be used, I noticed that many microcontrollers have an SPI. I thought I could use this along with a USB to programming it serially. I may also read the data serially (using shift registers) into the computer. This way, I think, I can establish communication of some sort between the two. But I am not sure if my computer will allow me to write to a USB port without any identifiable device being connected.

I am aware I would have to write some code to make this smooth since, both the microcontroller and the computer have different clock speeds.

| improve this question | | | | |
\$\endgroup\$
  • 3
    \$\begingroup\$ But I do not want to buy an Arduino Why? It is one of the easiest ways to get started. Once you master Arduino you can always switch to something else or make your own setup. In my opinion you're only making your life harder with more chance of failure and giving up. It is much easier to go from something that just works (Arduino) to your own custom solution which needs to have all the details right, details you do not know about yet. \$\endgroup\$ – Bimpelrekkie Nov 29 '19 at 10:54
  • 5
    \$\begingroup\$ Usually hobbysts use USB-SerialTTL cable with microcontroller and a serial terminal in PC \$\endgroup\$ – Mitu Raj Nov 29 '19 at 10:54
  • 1
    \$\begingroup\$ "This creates a problem in programming the microcontroller." Are you asking about how to flash the MCU or how to establish a MCU -> PC communication as part of the application? Those are very different things. \$\endgroup\$ – Lundin Nov 29 '19 at 12:01
  • 1
    \$\begingroup\$ @VishalDalwadi UART/RS-232 is the simplest way to communicate between MCU and PC. But you really don't want to upload code that way. It is possible through skunky bootloaders but that's needlessly painful and not something I'd recommend anyone to do, least of all beginners. Modern MCUs have in-circuit debuggers for that, from USB to SWD/JTAG. \$\endgroup\$ – Lundin Nov 29 '19 at 12:41
  • 2
    \$\begingroup\$ I started with Arduino because it is fun and quickly develops in us interest and curiosity towards embedded electronics. Which I think is important for a beginner to learn further things 😊 \$\endgroup\$ – Meenie Leis Nov 29 '19 at 13:52
2
\$\begingroup\$

An Arduino does not have to be a pre-fabricated board - it can be as simple as a microcontroller IC and some support components.

An eg basic Arduino Nano clone from Asia for under $US3 incl shipping gives you a few basic ICs a voltage regulator, a USB to serial interface and some support firmware to allow bootloading from USB. You gain nothing by not starting with a few parts on a board and the bootloader and free environment. Once running you can pursue whatever purist directions that seem good.

Struggling with months to achieve what can be done in hours in setting up an Arduino will teach you much, but there are far far far better ways to use the same learning time.

I built my first microcontroller system on strip board about 45 years ago!!!
Based on a Nat Semi SC/MP.
NO O/S,
Binary toggle switch program and data input.
(No keyboard or keypad initially).
LED I/O (yes, we had LEDs :-) ).
No assembler (let alone an HLL).
Later we graduated to using Baudot code teleprinetrs - that we wrote our own code for.

So, yes, I know what you can learn the hard way.
Buy an Arduino to start :-).

You can learn far far far more quickly by starting with an Arduino and working DOWN once you have it running. Arduino use in no way misses out on ANY computer architecture aspects. You are doing yourself a massively large disservice by not starting with Arduino.


Arduino Bootloader:

What it does and why use it, & How to turn any appropriate AVR microcontroller IC into an Arduino.

An Arduino-less Arduino here
and
Adding a bootloader with ICSP here
and here
and here
Stack Exchange discussion here

What it is and what it does here

| improve this answer | | | | |
\$\endgroup\$
  • \$\begingroup\$ I really agree that Arduinos are great. But I also want to somehow want to communicate with it. This medium can then also be used to send the program to and receive output from it. \$\endgroup\$ – Vishal Dalwadi Nov 29 '19 at 12:33
  • \$\begingroup\$ Why would a newbie want a bootloader for? They are cumbersome and painful to troubleshoot. Just flash the MCU with your favourite ICD, you'll need one for meaningful debugging anyhow. \$\endgroup\$ – Lundin Nov 29 '19 at 12:44
  • 2
    \$\begingroup\$ @VishalDalwadi Why not start off making maximal use of your learning experience and then progress to adding frustration, difficulty and pointless troubleshooting in due course ? :-). | A bootloader is an integral part of most Arduino systems. It is not essential to use An Arduino in that manner BUT it is highly "newbie friendly" & invisible to beginners.See eg here re loading the bootloader from scratch if needs must. Thereafter or with commercially supplied units it operates seamlessly invisibly. \$\endgroup\$ – Russell McMahon Nov 29 '19 at 14:11
  • 1
    \$\begingroup\$ @RussellMcMahon I guess, I will just get an Arduino. \$\endgroup\$ – Vishal Dalwadi Nov 29 '19 at 14:41
  • 1
    \$\begingroup\$ @VishalDalwadi My son did computer science 101. They had him accessing web based data bases in no time. They taught him no fundamentals. I was appalled. Once he saw what he could achieve they drilled down. I was impressed. I did it the hard hard hard way. Don't. Start wity an Arduino. Then burrow ijto the system. As long as you are not one of the generation who has no clues what goes on underneath, and deson't care (and you obviously are not). You will learn faster this way. || For interest, where are you located? I'm in NZ. \$\endgroup\$ – Russell McMahon Nov 29 '19 at 15:02
1
\$\begingroup\$

USB and SPI are completely different and you cannot communicate between your computer and your microcontroller using SPI directly.

However in most (to not say all) of the current microcontroller eval boards you will be provided with an UART-to-USB converter, and thus you will be able to communicate with your PC using an UART.

| improve this answer | | | | |
\$\endgroup\$
  • \$\begingroup\$ I never said it was impossible but you cannot do it directly without additionnal material. Serial port and USB are differents btw. I don't see in any way how you could bit-bang from SPI to USB. \$\endgroup\$ – Wheatley Nov 29 '19 at 11:10
  • \$\begingroup\$ I think I can use a shift register to make it work. \$\endgroup\$ – Vishal Dalwadi Nov 29 '19 at 12:28
  • \$\begingroup\$ No, you cannot. Please spend some time understanding these things by working with an existing system of the same purpose. \$\endgroup\$ – Chris Stratton Nov 29 '19 at 13:35
1
\$\begingroup\$

Answer is simple: Serial.

Get yourself a UART-USB converter like this, write some code in whatever language you please in order to use a COM port for communication. Done.

Don't you worry about clock speeds and bit banging. No need to reivent the wheel.

| improve this answer | | | | |
\$\endgroup\$
  • \$\begingroup\$ This amounts to trying to design an Arduino alternative from scratch with no experience of using a correctly built and working one first. \$\endgroup\$ – Chris Stratton Nov 29 '19 at 13:22
  • \$\begingroup\$ @ChrisStratton sure, but that's what the OP said he wanted to do. " I do not want to buy an Arduino, although that is what would be easy... \$\endgroup\$ – Bruce Abbott Nov 29 '19 at 18:16
1
\$\begingroup\$

I noticed that many microcontrollers have an SPI. I thought I could use this along with a USB to programming it serially.

These are wildly different protocols, and building your own adapter between them is definitely a project for after you've learned a lot about microcontrollers.

On the other hand, you can just buy one:

The other approach is to use the dedicated programming interface on the microcontroller, which may be "JTAG" or something like "ST-LINK" for "SWD" parts. That lets you do all sorts of convenient things in a debugger, such as set breakpoints and inspect variables.

| improve this answer | | | | |
\$\endgroup\$
  • \$\begingroup\$ Thank you. I guess I start off from here. \$\endgroup\$ – Vishal Dalwadi Nov 29 '19 at 14:43
1
\$\begingroup\$

You need to avoid confusing Arduino the software environment and Arduino hardware.

There is nothing unique about the Arduino hardware and they are a very cost-effective way to obtain all the hardware for what you are requesting. You don't have to build any hardware if you don't wish to.

I often use Arduino hardware (either Nano or Uno for ~3$) but write the program using AVR-GCC and program the processor using Avrdude and the Arduino boot-loader.

The software is available free (I use Homebrew to install on my Mac but it also supports Windows and Linux).

The Arduino hardware incorporates a USB converter to allow serial communication with the host computer - just use printf() in your code and capture on the PC with your favorite terminal emulator (on a Mac I use "screen"). I usually include an RTOS that I wrote with a command line interpreter in my software to allow debugging and control as well as feeding back data to the PC. The fact that it is based on Arduino hardware in no way restricts what my software can do.

| improve this answer | | | | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.