Alternative of flash magic

Thread Starter

Djsarakar

Joined Jul 26, 2020
352
HI
I found a microcontroller board after long time but it's not working. I wrote C code in the keil software and used flash magic to program I think the problem with flash magic software, due to which I am not able to program it. In my many more attempts I have been able to program the microcontroller p89v51rd2 only twice.

When I try to program microcontroller, flash magic show message "Reset the device into ISP mode"

@jpanhalt , @MrChips

IMG_20200816_164040.jpg
 
Last edited:

jpanhalt

Joined Jan 18, 2008
10,496
I have only used Flash Magic once and that was to program an NXP LPC2134 chip using ISP. My interface to a desktop PC was an FTDI 3.3V cable. For some reason, the original chip in the device wouldn't go into boot loader mode so it could be erased. On trouble shooting, the TX and RX pins seemed shorted. I removed the chip and replaced it with a blank chip. Almost everything worked after that.

By that I mean the programming went smoothly, but at the end there was an error message that some register had changed. I assumed it was some configuration register that was programmed, so the error was ignored. I have tested the device since -- a T-962 reflow oven -- and everything seems to work.

Flash magic is pretty widely used as it is free. The most common error seems to be getting it to talk to the chip. Once that is accomplished, there seem to be relatively few problems with the program. I experienced some tiny glitches with the display, which may have been due to my video set-up. I am still using Win7. It was a little temperamental compared to what I am used to with MPLAB (Microchip), but a big part of that was probably my inexperience.

If the chip programmed and now doesn't work as expected, suspect it is the program, not the programmer.
 

Thread Starter

Djsarakar

Joined Jul 26, 2020
352
If the chip programmed and now doesn't work as expected, suspect it is the program, not the programmer.
But i'm using the same hex file that i did earlier
C:
#include <reg51.h>

void DELAY_ms(unsigned int ms_Count)
{
    unsigned int i, j;
    for(i=0; i<ms_Count; i++)
    {
        for(j =0; j<100; j++);
    }
}
int main()
{
   
    while(1)
    {
        P0 = 0xff; /* Turn ON all the leds connected to Ports */
        P1 = 0xff;
        P2 = 0xff;
        P3 = 0xff;
        DELAY_ms(500);
       
        P0 = 0x00; /* Turn OFF all the leds connected to Ports */
        P1 = 0x00;
        P2 = 0x00;
        P3 = 0x00;
        DELAY_ms(500);
    }

    return (0);
}
So I am afraid that flash magic can cause problems.
 

JohnInTX

Joined Jun 26, 2012
4,341
It sounds like a connection or timing problem. Even if your code is defective it should still load via Flash Magic.
If I read the descriptions right, Flash Magic tries to send a 'U' for auto-baud detection within a few hundred ms of reset to enter the bootloader. It uses the RTS and DTR lines from the serial port so make sure those are working.
Be sure your connections are good and your power supply is clean and stable.
If you are using a USB-RS232 adapter, don't use a cheapie. They are notorious for flaky operation. Many use counterfeit chips that just don't do the job.
If you are using a laptop with USB-RS232 adapter, try connecting a physical ground wire between the laptop (USB frame or other metal connector shell) and the board ground. I have seen some USB-RS232 adapters that don't have a continuous ground through the cable so the signals float around if you are talking to an isolated device.

Here is some other info that may help you troubleshoot:
https://www.flashmagictool.com/resources.html
The .PDF describes how the bootloader process works.
Good luck!
 

Attachments

Thread Starter

Djsarakar

Joined Jul 26, 2020
352
Be sure your connections are good and your power supply is clean and stable.
If you are using a USB-RS232 adapter, don't use a cheapie. They are notorious for flaky operation. Many use counterfeit chips that just don't do the job.
If you are using a laptop with USB-RS232 adapter, try connecting a physical ground wire between the laptop (USB frame or other metal connector shell) and the board ground.
JohnInTX I am sending you pictures of converts and usb charger wires and I have laptop. I worry most about laptops Could the laptop be damaged if the connections went wrong?

There are two wires of usb cable which one is ground

IMG_20200816_225737.jpg

IMG_20200816_225703.jpg
 

JohnInTX

Joined Jun 26, 2012
4,341
I'm not familiar with that particular USB converter so can't offer any opinion on it.

It looks like you are using 5V from a USB cable. That should work, I guess. It probably provide ground continuity between the laptop and the target board.
EDIT: where are you connecting the 5V from the USB? It looks from the photo and https://www.silicontechnolabs.in/index.php?route=product/product&product_id=56 that the board expects a 9V-18V AC or DC power from a wall adapter. The power is rectified, filtered, and regulated by a 3 terminal regulator (probably a 7805) to get the 5V board power. It is not meant to have you connect 5VDC to the 5V power bus unless there is a jumper that you can pull to isolate the on-board power supply from an external 5V source.

If the standard stuff is OK i.e. good power, good ground, good signal levels at the UART pins of the processor, I'd suspect the USB-RS232 converter or a bad connection/solder joint on the board or cable.
That's about all I can think of.

Good luck!
 
Last edited:

JohnInTX

Joined Jun 26, 2012
4,341
What is your goal? The PIC is very different than the 8051.

I use whatever chip has the peripheral, memory and speed I need for the job.
The Enhanced Midrange PIC16F1xxx stuff is very nice if you're programming in C. You can get an incredible variety of peripherals on them and they're pretty cheap.

But it depends on what you want to do. PIC is what I know and use the most for 8-bit applications but there are many other alternatives, even from Microchip since they bought Atmel.

If you want to try PIC and already have a power supply and PK3, then the linked board looks like a pretty cheap way to get started. I don't care for the included '877A. Compared to 18F and 16F1xxx the old midrange stuff like the '877A is not worth the effort. The good news is that 5V 40PIN DIP PICs all use the same basic pinout so you can choose your chip.
If you DON'T have the rated power supply and PK3, take a look at the development boards from Microchip. They come ready to go with a built-in debugger and power supply. All you need is a USB cable and MPLABX to get a free C compiler and access to an extensive code library and sample programs. The little NANO boards are great for one-off prototypes. The bigger ones have 'CLICK' ports so you can add all kinds of stuff from Mikroe and others.

If you are just starting out in PIC, consider just using the MPSIM (included with MPLABX). You can write and execute programs to learn programming techniques and problem-solving, inspect the IO and internal variables etc. all without any hardware at all. Not a bad way to start. Using MPSIM will also will teach you to learn the debugging techniques that you will need when you move to hardware. MPLABX with MPSIM supports ALL Microchip products PIC, PIC24, PIC32, AVR, ARM, DSP etc. Once you decide you like a particular architecture, peripheral set and development environment (all more important than a particular chip) then you can move to getting a development board.

Lastly, if you want to dabble in PIC assembly language know that MPLABX versions 5.40+ have dropped the full-featured MPASM assembler. You can find previous versions on Microchip.com. I use 5.10

Just my .02 Give it some thought and have at it.
Have fun!
 

Thread Starter

Djsarakar

Joined Jul 26, 2020
352
What is your goal? The PIC is very different than the 8051.

Have fun!
Main goal is to learn programming about the microcontroller. I see mostly using PIC microcontroller right now, better support. I want to make my career in automotive domain so I would like a controller that has CAN features.

I want the following features in pic controller
Fast speed , interttupt, USART, SPI, I2C, ADC, CAN ( would like to work on modbus)

Do you know any PIC microcontroller in which these features are available
 

JohnInTX

Joined Jun 26, 2012
4,341
Start here:
https://www.microchip.com/design-centers/can

Click around to see what is available. It is interesting that the AVR stuff is listed way before PIC stuff. You might find AVR a better choice.
FWIW, I've used the 18F4685 which has the peripherals you indicated. It performed well but that was awhile ago. If I were starting out with a clean sheet, I'd look at some of the newer options. For automotive, you should look at CAN, CAN-FD and LIN with whatever other peripherals you might want. Once you find an interesting part, see what development/evaluation boards there are to support it.

CAN and modbus are different things.
 

Thread Starter

Djsarakar

Joined Jul 26, 2020
352
I've used the 18F4685 which has the peripherals you indicated. It performed well but that was awhile ago. If I were starting out with a clean sheet, I'd look at some of the newer options
I found below link in my Google search
https://www.microchip.com/maps/Microcontroller.aspx

But I can't compare microcontroller in link that suit my needs.

Can you please suggest me some alternative of PiC18F4685 (newer options) with same features? I will have the option to buy a microcontroller
 
Last edited:

jpanhalt

Joined Jan 18, 2008
10,496
It seems the goal keeps changing. Sometimes PIC, sometime simple (like PIC12F), then more complex, and sometime you are working under a directive to use the STM32F407:
https://forum.allaboutcircuits.com/threads/stm32f407-microcontroller.171792/#post-1537775
My teacher had suggested me stm32f407 microcontroller. I have to make project in final year. The project has not been decided yet but she said that in my project I have to use STM32 microcontroller so I have to practice it
Which is it?
 

Thread Starter

Djsarakar

Joined Jul 26, 2020
352
It seems the goal keeps changing.
There was a lot of confusion but everything is clear now. I would like to work with the PIC18F microcontroller. I have noticed in research that ARM architecture is more difficult than PIC microcontroller. One advantage of selecting the PIC microcontroller is that it has more support

I will learn ARM later

Edit - cost of PIC18F4685 is 1,161rs
https://www.tanotis.com/products/mi...PEnkIG5P0Yj-IajmqVcYXN1xS62CcahRoC3j4QAvD_BwE

Can i get a new version of PIc18F4685 within 1,161rs?
 
Last edited:

JohnInTX

Joined Jun 26, 2012
4,341
The origin of the PIC architecture as a GP MCU was flawed from day one. It is instructional to examine the development of MCU hardware and how the design of the architecture was influenced.

The original concept of the PIC goes back to 1975 as a hardware I/O peripheral to the General Instrument CP1600 processor.
This was entirely driven by hardware requirements and PIC MCUs followed a minimalist design concept not unlike the RCA 1802 in 1973. There was no concept of stacks. Exception processing was implemented by context or bank switching.

Compare this with Motorola 68HC11 design in 1984 and Atmel AVR in 1996. By this time, hardware stack handling was the norm in any MCU. It is important to note that the design of the Atmel AVR was facilitated by software simulation and influenced by compiler design.

In other words, Microchip PIC design was hardware driven while Atmel AVR design was software driven. With due respect to Microchip, most of the limitations of the original PIC design have been eliminated in their more recent higher-end models.
The irony is that Atmel is now owned by Microchip.
It seems the goal keeps changing. Sometimes PIC, sometime simple (like PIC12F), then more complex, and sometime you are working under a directive to use the STM32F407:
https://forum.allaboutcircuits.com/threads/stm32f407-microcontroller.171792/#post-1537775
Which is it?
Two excellent pieces of information for you! If your teacher suggested ARM you should listen. Mr. Chips correctly points out that the popularity of 8-bit PIC isn't because it's a wonderful architecture. PICs were among the first uControllers to be self-contained, field programmable, and cheap enough to begin to replace a board full of SSI IC logic. That and good support from the company as well as a very low cost of entry resulted in PIC becoming very popular, despite the limitations imposed by the architecture.

I don't think I would recommend you learning a PIC when the final target is ARM. You'll wind up investing a lot of time learning how to compensate for the PIC's banked memory, limited interrupt and stack capability, C language limitations, etc. that won't apply much if you need ARM. It's easy for me to say because I have a lot of experience in uC development but I'd be tempted to just get an ARM demo board and start with some simple tasks, flash an LED, send 'Hello World' to the UART, make an interrupt-driven timer etc. then go from there. The learning curve is arguably steeper but at least the time you invest will directly apply to the final project. Try it in a simulator to see how it goes.

I'll leave it to the more experienced ARM guys here to tell you if that's a good path to follow.

You should also do a realistic evaluation of your problem solving -> program design -> coding skills. If you're not very solid in that, it doesn't matter what processor you pick.

Wish I had a better answer for you but give it some thought.
 
Last edited:

Thread Starter

Djsarakar

Joined Jul 26, 2020
352
My teacher also believes that it doesn't matter which microcontroller you are using. She said we should know how to solve the problem. If we know this method then we can work on any microcontroller. I believe My teacher will also allow me to work on PIC. Her biggest concern is that the project I am working on should be a major project which is useful for the common people. That is why I have downloaded many research papers and I am studying them. In my class there are other students they are working on the PIC. I want to buy a development board for myself so that I can practice at my home. It will benefit me that I can do different experiments. So I can learn a lot.

I have power supply and pic kit 3 now available and I am looking only micro. I bought two microcontroller boards (8051 )but they are not working. Recently I have just made a mistake in buying a microcontroller. I have also canceled my order. I want to spend my money at the right place so that I don't have to buy new microcontrollers again and again.

I appreciate all of yours advices
 
Last edited:

Thread Starter

Djsarakar

Joined Jul 26, 2020
352
Do you know why the microcontroller board didn’t work? If you don’t, you may find yourself buying boards and chips over and over... Even when you’re trying to avoid doing so.

Learn from your mistakes!
You are absolutely right My first microcontroller had damaged due to my wrong connection. , And second board I do not understand the reason for it yet Why the 8051 board that I have right now is not workingt. I tried to solve the problem as much as I could. And I'm still trying to find problem
 

trebla

Joined Jun 29, 2019
215
I think the newest PIC18 part with CAN support is PIC18F4685, Microchip is moved CAN targeted applications to 16 bit (dsPIC33, PIC24) and PIC32 families, leaving for newer PIC18 families to support simpler interfaces like LIN. However is there RS485 support and you can use CAN tranceiver IC-s and software libraries.
 

trebla

Joined Jun 29, 2019
215
By the way, Microchip does not recommends design with PIC18F46K22 anymore. They suggest new Q series, for example PIC18F46Q43.
 

JohnInTX

Joined Jun 26, 2012
4,341
I show the 'Q' stuff as future products which might be an issue.

For reference, the 18Fxxxx lineup with CAN starts on page 27(!) in the tables here:
https://www.microchip.com/design-centers/can/can-2-mcus
If you already have a PK3, it looks like a 40 Pin DIP like 18F45K80 would drop into the board you linked earlier. You would need to wire up a CAN transceiver for CAN.

If you don't have a PK3 you are free to explore any of the AVR stuff listed earlier in the tables, too.

If you are really just starting PIC, you might just want to get the cheapest demo board that has a resident debugger like a Curiosity Nano. You can have lots of fun with all things PIC then upgrade to CAN or tack on an external CAN controller. Realistically, you have a lot of ground to cover before even considering CAN. You'll need at least TWO nodes to talk to each other and preferably some kind of CAN analyzer to inspect the bus traffic. Not trivial for a newbie but everyone starts somewhere..

Do consider my original observation that you can do and learn a lot using MPSIM and postpone your hardware decisions until you have a better understanding of what your final goal will require.
 
Top