Checking pic16f877 and Atmega32A  - Page 1
Forum section: electronics / general

author: VSV_electron
author_rank: Regular Contributor
timestamp: October 20, 2022, 08:09:38 pm
content: 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.

author: MikeK
author_rank: Super Contributor
timestamp: October 20, 2022, 09:08:43 pm
content: 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.

author: jpanhalt
author_rank: Super Contributor
timestamp: October 20, 2022, 09:38:29 pm
content: 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.

author: Lindley
author_rank: Regular Contributor
timestamp: October 21, 2022, 09:19:10 am
content: 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 PIC18F46K22The 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.

author: DavidAlfa
author_rank: Super Contributor
timestamp: October 21, 2022, 10:15:05 am
content: The mcu will be blank, you can't test the properly without some program loaded.

author: VSV_electron
author_rank: Regular Contributor
timestamp: October 21, 2022, 01:18:00 pm
content: Quote from: jpanhalt on October 20, 2022, 09:38:29 pmSorry, 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?

author: VSV_electron
author_rank: Regular Contributor
timestamp: October 21, 2022, 01:22:43 pm
content: Quote from: Lindley on October 21, 2022, 09:19:10 amNot 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. :-)

author: jpanhalt
author_rank: Super Contributor
timestamp: October 21, 2022, 01:38:54 pm
content: Quote from: VSV_electron on October 21, 2022, 01:18:00 pmSorry, based on your experience, I did not take this statement literally:QuoteThus, 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:movlb 1movlw b'01110000' ;PLLEN disabled, 1110=8 MHz |B1movwf OSCCON ; |B1btfss OSCSTAT,HFIOFS ;check HF stable |B1bra $-1 ;keep checking |B1movlb 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.

author: pcprogrammer
author_rank: Super Contributor
timestamp: October 21, 2022, 01:41:34 pm
content: Quote from: VSV_electron on October 21, 2022, 01:18:00 pmHow 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.

author: DavidAlfa
author_rank: Super Contributor
timestamp: October 21, 2022, 01:53:00 pm
content: What's the target of this?Checking they're working or start a claim before the time runs out?

author: Ian.M
author_rank: Super Contributor
timestamp: October 21, 2022, 02:35:58 pm
content: 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.pngSoftware (Win):https://www.qsl.net/dl4yhf/winpicpr.htmlThe 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.

author: DavidAlfa
author_rank: Super Contributor
timestamp: October 21, 2022, 03:27:30 pm
content: The ch341A also can program the avr using a ch341a + NeoProgrammer.A pickit clone is pretty inexpensive...

author: MikeK
author_rank: Super Contributor
timestamp: October 21, 2022, 04:39:15 pm
content: Quote from: DavidAlfa on October 21, 2022, 03:27:30 pmWhere are you seeing these for cheap? The lowest I've seen one for is $23.

author: VSV_electron
author_rank: Regular Contributor
timestamp: October 21, 2022, 04:56:45 pm
content: Quote from: DavidAlfa on October 21, 2022, 01:53:00 pmChecking they're working TO start a claim before the time runs out.

author: VSV_electron
author_rank: Regular Contributor
timestamp: October 21, 2022, 05:01:12 pm
content: Quote from: pcprogrammer on October 21, 2022, 01:41:34 pmFrom 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."

author: VSV_electron
author_rank: Regular Contributor
timestamp: October 21, 2022, 05:26:52 pm
content: 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?

author: DavidAlfa
author_rank: Super Contributor
timestamp: October 21, 2022, 05:43:53 pm
content: 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.

author: pcprogrammer
author_rank: Super Contributor
timestamp: October 21, 2022, 07:17:42 pm
content: Quote from: VSV_electron on October 21, 2022, 05:01:12 pmSorry, I missed that oneBut 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.

author: mariush
author_rank: Super Contributor
timestamp: October 21, 2022, 07:59:51 pm
content: 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) andhttps://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/vq1r09jhedit : 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

author: jpanhalt
author_rank: Super Contributor
timestamp: October 21, 2022, 08:23:17 pm
content: Quote from: mariush on October 21, 2022, 07:59:51 pmThat 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.

author: MikeK
author_rank: Super Contributor
timestamp: October 21, 2022, 08:57:34 pm
content: Yes, the Snap won't do HV programming:Quote

author: Zoli
author_rank: Frequent Contributor
timestamp: October 23, 2022, 12:09:21 am
content: Quote from: VSV_electron on October 20, 2022, 08:09:38 pmAdd crystals, and check if you get a signal out of them; if yes, most likely they working.

author: Ian.M
author_rank: Super Contributor
timestamp: October 23, 2022, 01:31:31 am
content: That wont work for a blank PIC16F877, as it isn't configured for a crystal!Code:Address Value Field Category Setting2007 3FFF FOSC Oscillator Selection bitsRC oscillatorWDTE Watchdog Timer Enable bitWDT enabledPWRTE Power-up Timer Enable bitPWRT disabledCP FLASH Program Memory Code Protection bitsCode protection offBOREN Brown-out Reset Enable bitBOR enabledLVP Low Voltage In-Circuit Serial Programming Enable bitRB3/PGM pin has PGM function; low-voltage programming enabledCPD Data EE Memory Code ProtectionCode Protection offWRT FLASH Program Memory Write EnableUnprotected program memory may be written to by EECON controlA 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.

author: Zoli
author_rank: Frequent Contributor
timestamp: October 23, 2022, 02:38:32 am
content: Quote from: Ian.M on October 23, 2022, 01:31:31 amThanks for chiming in with the details; the idea was to try to start the oscillator, as is something which works independently.

author: DavidAlfa
author_rank: Super Contributor
timestamp: October 23, 2022, 04:00:33 pm
content: 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 msAlthough 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.

author: bidrohini
author_rank: Regular Contributor
timestamp: October 25, 2022, 02:10:44 pm
content: I think you have to wait until the programmers arrive. I used to test PIC chips and AVR chips. I used PIC programmers to test PIC chips and AVR programmers for AVR chips. Both of the MCUs that you've mentioned have 40 pins. So, you can place them directly on the zif socket of the programmer. If your programmer software detects the chip and you can read the chips with your software, the chips will be QC passed.