Author Topic: Checking pic16f877 and Atmega32A  (Read 3024 times)

0 Members and 1 Guest are viewing this topic.

Offline VSV_electronTopic starter

  • Regular Contributor
  • *
  • Posts: 122
  • Country: ee
Checking pic16f877 and Atmega32A
« on: October 20, 2022, 08:09:38 pm »
Hello,

I ordered a few MCUs, couple pic16f877 and Atmega32A of each and a few more, all 40 pin DIP.
The programmers/dev boards should arrive in a month but I need to check that the MCU units are at least not completely defunct.
Please suggest me a minimal setup and procedure to check the MCU units without writing/reading them. Just to confirm they are at least potentially functional.

What I've got at the moment: a Rigol 2-channel scope, a multimeter, a breadboard, some passive and semi components, Lab power supply.

I'm just re-starting the hobby. I don't have much experience but over 30 years ago I soldered/assembled and set-up a ZX-Spectrum Z80 computer kit using basic equipment such as a scope and multimeter. I had a formal education in digital electronics but I have very little experience with MCUs and electronics in general as I never worked in the field.
 

Offline MikeK

  • Super Contributor
  • ***
  • Posts: 1316
  • Country: us
Re: Checking pic16f877 and Atmega32A
« Reply #1 on: October 20, 2022, 09:08:43 pm »
I don't know about the ATmega, but the PIC will boot up with its pins as inputs.  That is, the pins will be high impedance, not outputing a low nor a high...they won't be sourcing or sinking current.

"Testing" them without programming them seems odd, though.  Also the 16F877 is quite old now...modern PIC's are better in every way, unless this is an issue of availability.
 

Online jpanhalt

  • Super Contributor
  • ***
  • Posts: 3816
  • Country: us
Re: Checking pic16f877 and Atmega32A
« Reply #2 on: October 20, 2022, 09:38:29 pm »
With the PIC's you can check that the system clock is running.  That is very few Assembly instructions using a standard startup.  Don't know about Atmega, but suspect  it is not much different.  If you are worried about counterfeit chips, why did you buy from an unreliable source?  Presumably, even a counterfeit will have an oscillator.
 
The following users thanked this post: VSV_electron

Offline Lindley

  • Regular Contributor
  • *
  • Posts: 206
  • Country: gb
Re: Checking pic16f877 and Atmega32A
« Reply #3 on: October 21, 2022, 09:19:10 am »
Though a very good chip in its day , and we started our Assembly programming on them, but the pic16f877/A is over 20 years old  so much better to use one of the more modern and  near compatible versions like the 16F887A  or PIC18F46K22

The Atmega, think it would be much better to by a cheap and complete Arduino clone Nano or Uno board, that way you can test it working out of the box, no separate programmer needed if using the free Arduino IDE.

You do not mention what programming languages you are intending to use for them ? but another intersting chip to look into in the future is the ESP32 which makes Wifi and BT very easy using the Arduino C++ example code.
« Last Edit: October 21, 2022, 09:21:17 am by Lindley »
 
The following users thanked this post: VSV_electron

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6278
  • Country: es
Re: Checking pic16f877 and Atmega32A
« Reply #4 on: October 21, 2022, 10:15:05 am »
The mcu will be blank, you can't test the properly without some program loaded.
« Last Edit: October 21, 2022, 01:44:59 pm by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 
The following users thanked this post: VSV_electron

Offline VSV_electronTopic starter

  • Regular Contributor
  • *
  • Posts: 122
  • Country: ee
Re: Checking pic16f877 and Atmega32A
« Reply #5 on: October 21, 2022, 01:18:00 pm »
With the PIC's you can check that the system clock is running.  That is very few Assembly instructions using a standard startup.  Don't know about Atmega, but suspect  it is not much different.  If you are worried about counterfeit chips, why did you buy from an unreliable source?  Presumably, even a counterfeit will have an oscillator.

Sorry, I didn't understand you. What do you mean by "That is very few Assembly instructions using a standard startup."? I can't load anything on chips now even if it's only  a few instructions because I've got no programmer/uploader.
Do you mean the PIC 887 will startup with the "clock out" running on the corresponding pin? Is that what you say?
 

Offline VSV_electronTopic starter

  • Regular Contributor
  • *
  • Posts: 122
  • Country: ee
Re: Checking pic16f877 and Atmega32A
« Reply #6 on: October 21, 2022, 01:22:43 pm »
...
The Atmega, think it would be much better to by a cheap and complete Arduino clone Nano or Uno board, that way you can test it working out of the box, no separate programmer needed if using the free Arduino IDE.
...

Not cheaper, two Atmega 89* for the price of 1 UNO. Besides Arduino lends itself to propagating the "arduinoers". That's a very specific camp of electronics experts. :-)
 

Online jpanhalt

  • Super Contributor
  • ***
  • Posts: 3816
  • Country: us
Re: Checking pic16f877 and Atmega32A
« Reply #7 on: October 21, 2022, 01:38:54 pm »
Sorry, I didn't understand you. What do you mean by "That is very few Assembly instructions using a standard startup."? I can't load anything on chips now even if it's only  a few instructions because I've got no programmer/uploader.
Do you mean the PIC 887 will startup with the "clock out" running on the corresponding pin? Is that what you say?

Sorry, based on your experience, I did not take this statement literally:
Quote
Please suggest me a minimal setup and procedure to check the MCU units without writing/reading them.
Thus, a very short program copied from somewhere else would be allowed even though it's clear you did not want to have a useful program.*  Clearly, that assumption was wrong.

I agree with the statement by DavidAlfa.  That is, there is no way to tell whether they will be functional by just looking at them.  The chips are supposedly blank.

*Should you like to do that, many contributors here, including myself, could post the code for doing that.  Here is what it would look like for a PIC12F1840:
Code: [Select]
     movlb     1
     movlw     b'01110000'    ;PLLEN disabled, 1110=8 MHz                       |B1
     movwf     OSCCON         ;                                                 |B1
     btfss     OSCSTAT,HFIOFS ;check HF stable                                  |B1
     bra       $-1            ;keep checking                                    |B1
     movlb     0              ;                                                 |B0
<light LED>
The instruction "btfss   OSCSTAT,HFIOFS" checks if the oscillator is running.  If not, if keeps checking.  If it is running, it goes to the rest of the code, which could be to flash an LED or you could simply put clock out to a pin.  EDIT: Clock out to a pin would be in the configuration settings, but setting only the configuration still requires programming.
« Last Edit: October 21, 2022, 01:44:31 pm by jpanhalt »
 
The following users thanked this post: VSV_electron

Online pcprogrammer

  • Super Contributor
  • ***
  • Posts: 4421
  • Country: nl
Re: Checking pic16f877 and Atmega32A
« Reply #8 on: October 21, 2022, 01:41:34 pm »
I can't load anything on chips now even if it's only  a few instructions because I've got no programmer/uploader.

How are you planning on using the chips then?

The Atmega32A also needs to be programmed to test it. A microcontroller like this, when bought off the shelf will be blank and can't be tested with what you listed as available equipment.

By the sound of it, you would be better of looking into the arduino world of using microcontrollers. You can get cheapish clones from Aliexpress to play with. They can easily be programmed and tested based on many examples that can be found on the internet.

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6278
  • Country: es
Re: Checking pic16f877 and Atmega32A
« Reply #9 on: October 21, 2022, 01:53:00 pm »
What's the target of this?
Checking they're working or start a claim before the time runs out?
« Last Edit: October 21, 2022, 03:25:46 pm by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 13133
Re: Checking pic16f877 and Atmega32A
« Reply #10 on: October 21, 2022, 02:35:58 pm »
You'll need some sort of programmer in your hands at least a few days before the return/dispute window closes for the MCUs, so you can check device IDs, check they are blank, and load firmware to test and exercise all I/O pins.

If you cant beg, buy or borrow a PICkit 2 (possibly a clone), which can program these vintage PICs, and also AVRs (using the AVRDUDE software), hear are a few suggestions for DIYable programming solutions:

AVRs can generally be programmed using AVRDUDE + an Arduino running the ArduinoISP sketch.

PICs are a little trickier.  Assuming you've got a legacy PC available with a real parallel port, David Tait's parallel port PIC programmer (7407 +PNPs variant) is known to be reliable.

Schematic: http://linuxgazette.net/issue79/misc/sebastian/pp.png
Software (Win): https://www.qsl.net/dl4yhf/winpicpr.html

The once popular serial port 'JDM' PIC programmer circuit is simpler but has issues with modern PCs and serial ports that aren't direct from the motherboard Southbridge, or an ISA or PCI COM port card.   It also doesn't permit the PC and target PIC to share a common ground - not a big problem if you are programming out of circuit, but potentially disastrous if you attempt to program a target board without fully disconnecting it.  YMMV.

Edit:  N.B. the Tait programmer's 7407 must be a real bipolar TTL version (e.g. original 7400 series, 74S, 74LS, 74ALS etc.), not any CMOS version (e.g. not anything with a 'C' in the part no.), as it is being used for level shifting above its Vcc rail.
« Last Edit: October 21, 2022, 09:18:21 pm by Ian.M »
 
The following users thanked this post: VSV_electron

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6278
  • Country: es
Re: Checking pic16f877 and Atmega32A
« Reply #11 on: October 21, 2022, 03:27:30 pm »
The ch341A also can program the avr using a ch341a + NeoProgrammer.
A pickit clone is pretty inexpensive...
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 
The following users thanked this post: VSV_electron

Offline MikeK

  • Super Contributor
  • ***
  • Posts: 1316
  • Country: us
Re: Checking pic16f877 and Atmega32A
« Reply #12 on: October 21, 2022, 04:39:15 pm »
A pickit clone is pretty inexpensive...

Where are you seeing these for cheap?  The lowest I've seen one for is $23.
 

Offline VSV_electronTopic starter

  • Regular Contributor
  • *
  • Posts: 122
  • Country: ee
Re: Checking pic16f877 and Atmega32A
« Reply #13 on: October 21, 2022, 04:56:45 pm »
What's the target of this?
Checking they're working or start a claim before the time runs out?

Checking they're working TO start a claim before the time runs out.
 

Offline VSV_electronTopic starter

  • Regular Contributor
  • *
  • Posts: 122
  • Country: ee
Re: Checking pic16f877 and Atmega32A
« Reply #14 on: October 21, 2022, 05:01:12 pm »
I can't load anything on chips now even if it's only  a few instructions because I've got no programmer/uploader.

How are you planning on using the chips then?
...

From my original post: "The programmers/dev boards should arrive in a month but I need to check that the MCU units are at least not completely defunct."
 

Offline VSV_electronTopic starter

  • Regular Contributor
  • *
  • Posts: 122
  • Country: ee
Re: Checking pic16f877 and Atmega32A
« Reply #15 on: October 21, 2022, 05:26:52 pm »
Not to spawn out another thread let me ask here another question taking advantage of the existing thread:

When interfacing an MCU to a relay and using an optocoupler for galvanic separation does it require two separate power supplies to make the galvanic separation meaningful?
In the example circuit (see the link below) the MCU signal circuit is 5 VCD and the relay control circuit is 12 VDC.
https://www.electroschematics.com/microcontroller-relay-interface-and-driver/

From the proposed schematic does it follow the two supplied voltage sources should be galvanically independent?

What I mean is that the nominal relay coil pull-in Voltage could be 5 VDC (or even 3 VDC depending on the particular relay) and that would be more convenient in terms of using the common power supply line for both the MCU and relay control circuits but I understand that is not what the proposed schematic infers. Correct?
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6278
  • Country: es
Re: Checking pic16f877 and Atmega32A
« Reply #16 on: October 21, 2022, 05:43:53 pm »
Then, unless you find someone who can program them, you're pretty much screwed. Hopefully they will be ok.
You don't forcefully need galvanic isolation to drive a relay, but if you do then yes, you need separate power supplies with separate grounds, otherwise it's not galvanic isolation anymore, just PIC-transistor.
Adding a series diode (Or a zener at the PIC pin) with the transistor base resistor will avoid incoming dangerous voltages in case of transistor breaking, if that's your concern.
« Last Edit: October 21, 2022, 05:56:17 pm by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 
The following users thanked this post: VSV_electron

Online pcprogrammer

  • Super Contributor
  • ***
  • Posts: 4421
  • Country: nl
Re: Checking pic16f877 and Atmega32A
« Reply #17 on: October 21, 2022, 07:17:42 pm »
From my original post: "The programmers/dev boards should arrive in a month but I need to check that the MCU units are at least not completely defunct."

Sorry, I missed that one :o

But like DavidAlfa wrote, you need a programmer to be able to test the chips.

For your other question I can add that it does not need to be a bipolar junction transistor. You can use a mosfet, which has the advantage of no current being drawn from the MCU and less loss in the junction.

Offline mariush

  • Super Contributor
  • ***
  • Posts: 5144
  • Country: ro
  • .
Re: Checking pic16f877 and Atmega32A
« Reply #18 on: October 21, 2022, 07:59:51 pm »
MPLAB Snap is around $35 now.... at some point it used to be $15 and even less.  Here's links :

https://www2.mouser.com/ProductDetail/Microchip-Technology-Atmel/PG164100?qs=w%2Fv1CP2dgqoaLDDBjfzhMQ%3D%3D   (mouser)  and
https://www.microchip.com/en-us/development-tool/PG164100  (microchip store)
https://www.digikey.com/en/products/detail/microchip-technology/PG164100/9562532?s=N4IgTCBcDaILYAcA2BDARgAgM4DsUJAF0BfIA (digikey, no stock)


However, I don't think it would be able to program that old PIC chip, because it can only do low voltage programming. I think that ancient PIC requires high voltage programming. PicKit 3 would work, but is it worth 60-70 bucks right now? Debatable, if you just want to play with some PICs.

There's loads of modern PIC16F chips which are practically much easier to work with than those old DIP chips ... some examples : https://www.digikey.com/short/vq1r09jh

edit  : The list of supported devices is here : https://packs.download.microchip.com/DeviceDoc/Device_Support.pdf

(the link is from the Readme for MPLAB Snap.htm  inside MPLAB X IDE Release Notes which can be downloaded from here (also the IDE is here) : https://www.microchip.com/en-us/tools-resources/develop/mplab-x-ide#tabs
« Last Edit: October 21, 2022, 08:12:20 pm by mariush »
 
The following users thanked this post: VSV_electron

Online jpanhalt

  • Super Contributor
  • ***
  • Posts: 3816
  • Country: us
Re: Checking pic16f877 and Atmega32A
« Reply #19 on: October 21, 2022, 08:23:17 pm »
However, I don't think it would be able to program that old PIC chip, because it can only do low voltage programming. I think that ancient PIC requires high voltage programming. PicKit 3 would work, but is it worth 60-70 bucks right now? Debatable, if you just want to play with some PICs.

That chip has a PGM pin to enable low LV programming.  I have never used that chip or SNAP , so I cannot say whether they work together.  My main programmer is an ICD3, and it should work with that chip in either mode.
 

Offline MikeK

  • Super Contributor
  • ***
  • Posts: 1316
  • Country: us
Re: Checking pic16f877 and Atmega32A
« Reply #20 on: October 21, 2022, 08:57:34 pm »
Yes, the Snap won't do HV programming:

Quote
The MPLAB® Snap In-Circuit Debugger (PG164100) is an ultra-low priced debugging solution for projects not
requiring high-voltage programming or advanced debug features. Therefore, it supports many of Microchip’s newer
MCU offerings but not some legacy products.
 

Online Zoli

  • Frequent Contributor
  • **
  • Posts: 552
  • Country: ca
  • Grumpy old men
Re: Checking pic16f877 and Atmega32A
« Reply #21 on: October 23, 2022, 12:09:21 am »
...
Please suggest me a minimal setup and procedure to check the MCU units without writing/reading them. Just to confirm they are at least potentially functional.
...
Add crystals, and check if you get a signal out of them; if yes, most likely they working.
 
The following users thanked this post: VSV_electron

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 13133
Re: Checking pic16f877 and Atmega32A
« Reply #22 on: October 23, 2022, 01:31:31 am »
That wont work for a blank PIC16F877, as it isn't configured for a crystal!
Code: [Select]
   Address    Value   Field         Category                 Setting         

    2007      3FFF  FOSC    Oscillator Selection bitsRC oscillator             
                    WDTE    Watchdog Timer Enable bitWDT enabled               
                    PWRTE   Power-up Timer Enable bitPWRT disabled             
                    CP      FLASH Program Memory Code Protection bitsCode protection off       
                    BOREN   Brown-out Reset Enable bitBOR enabled               
                    LVP     Low Voltage In-Circuit Serial Programming Enable bitRB3/PGM pin has PGM function; low-voltage programming enabled
                    CPD     Data EE Memory Code ProtectionCode Protection off       
                    WRT     FLASH Program Memory Write EnableUnprotected program memory may be written to by EECON control
A blank (factory fresh or erased) PIC16F877 will have the above config and to get it to run, you'd need to pull /MCLR high with a 10K resistor to Vdd, pull PGM(RB3) low also with a 10K resistor and provide a RC oscillator circuit consisting of a pullup + a capacitor to ground both connected to OSC1.  It will then output a FOSC/4 squarewave on OSC2.  See datasheet FIGURE 12-3: RC OSCILLATOR MODE.  I would suggest Rext=5K6 and Cext=100pF for an oscillator frequency of about 1MHz @5V Vdd.  Also note BOR is enabled so you need Vdd>4.35V.
 
The following users thanked this post: Zoli, VSV_electron

Online Zoli

  • Frequent Contributor
  • **
  • Posts: 552
  • Country: ca
  • Grumpy old men
Re: Checking pic16f877 and Atmega32A
« Reply #23 on: October 23, 2022, 02:38:32 am »
That wont work for a blank PIC16F877, as it isn't configured for a crystal!
Code: [Select]
   Address    Value   Field         Category                 Setting         

    2007      3FFF  FOSC    Oscillator Selection bitsRC oscillator             
                    WDTE    Watchdog Timer Enable bitWDT enabled               
                    PWRTE   Power-up Timer Enable bitPWRT disabled             
                    CP      FLASH Program Memory Code Protection bitsCode protection off       
                    BOREN   Brown-out Reset Enable bitBOR enabled               
                    LVP     Low Voltage In-Circuit Serial Programming Enable bitRB3/PGM pin has PGM function; low-voltage programming enabled
                    CPD     Data EE Memory Code ProtectionCode Protection off       
                    WRT     FLASH Program Memory Write EnableUnprotected program memory may be written to by EECON control
A blank (factory fresh or erased) PIC16F877 will have the above config and to get it to run, you'd need to pull /MCLR high with a 10K resistor to Vdd, pull PGM(RB3) low also with a 10K resistor and provide a RC oscillator circuit consisting of a pullup + a capacitor to ground both connected to OSC1.  It will then output a FOSC/4 squarewave on OSC2.  See datasheet FIGURE 12-3: RC OSCILLATOR MODE.  I would suggest Rext=5K6 and Cext=100pF for an oscillator frequency of about 1MHz @5V Vdd.  Also note BOR is enabled so you need Vdd>4.35V.
Thanks for chiming in with the details; the idea was to try to start the oscillator, as is something which works independently.
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6278
  • Country: es
Re: Checking pic16f877 and Atmega32A
« Reply #24 on: October 23, 2022, 04:00:33 pm »
Had some old but never used PIC16LF767 in a box, the Config bits also select the RC oscillator when in erased state.
Connected it in the most very simple way, I can confirm the RC oscillator works.
Also, as the WDT is enabled by default, you'll see the system resetting every few hundreds of ms

Although the datasheets recommend resistors between 3K and 100K, it ran ok with 470ohms.
However, better you stay within the recommended values, it could work or not, falsely making you to think they're defective chips.
3K3 and 100pF should be a safe value.

Then there's the possibility they came pre-programmed but never used, and they're re-selling them.
« Last Edit: October 23, 2022, 07:52:06 pm by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 
The following users thanked this post: VSV_electron


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf