Weird PIC12F1840 - Page 1
Forum section: electronics / general

author: 1001
author_rank: Contributor
timestamp: March 24, 2021, 12:18:30 pm
content: I bought ten PIC12F1840I/SN on aliexpress and I can't program these (I have used original PICKIT 3 and GALEP 5), I got Device ID error, 1B C4 instead of 1B 80.I am able to program these mcu choosing a low voltage version PIC12LF1840 so I used a simple test to blink a led at 5.5Vdd and the device work well.My question is if this mcu was been PIC12LF1840 it would have to burn at 5.5 Vdd, or am I wrong?

author: Ian.M
author_rank: Super Contributor
timestamp: March 24, 2021, 12:48:20 pm
content: Many 8 bit microchip MCUs are remarkably rugged and survive voltages significantly in excess of abs. max. Vdd for a while. How long a specific chip will run like that is anyone's guess - it may only run an hour but another may run for months or years. Also they'd probably be more likely to fail at elevated temperatures.There's an alternative method of distinguishing them. SeePIC12(L)F1840 datasheetsection 14.3 p111. Basically there's a bit in the FVRCON SFR, (FVRRDY) that's stuck at 1 on the 'F' version and indicates FVR state on the LF version (default: 0 disabled/not ready). Write a minimal firmware that copies it to an output pin.I'd say they are definitely suspect - either pulls that have been improperly erased corrupting the chip ID, or remarked LF ones.

author: 1001
author_rank: Contributor
timestamp: March 27, 2021, 12:16:27 pm
content: Thanks Ian.M, I wrote a simple firmware to know the value of FVRRDY, when I select sw simulator to debug I get always FVRRDY=0, if I use pickit (Vdd=5V) to debug the real mcu I get always FVRRDY=1. Is my PICKIT reading the real value of FVRRDY of the mcu? In this case the value of 1 indicates the mcu is PIC12F1840 with a wrong Device ID.

author: Ian.M
author_rank: Super Contributor
timestamp: March 27, 2021, 01:01:40 pm
content: I don't trust what MCC is doing to initialize the PIC unless you've been through the disassembly line by line to confirm it is *NOT* enabling the FVR. The debugger says FVRCON:FVREN is zero, but that requires faith in the debugger. I *generally* trust it, but not when I need to *prove* that hardware is Go/NoGo. You can generally assume that the simulator doesn't reliably (if at all) support analog(ish) peripherals . . .Here's the MPASM version of that minimal firmware:Code:#include "p12f1840.inc"; PIC12F1840 Configuration Bit Settings; CONFIG1; __config 0xC9E4__CONFIG _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_OFF & _MCLRE_ON & _CP_OFF & _CPD_OFF & _BOREN_OFF & _CLKOUTEN_OFF & _IESO_OFF & _FCMEN_OFF; CONFIG2; __config 0xFCFF__CONFIG _CONFIG2, _WRT_OFF & _PLLEN_OFF & _STVREN_OFF & _BORV_LO & _LVP_ONerrorlevel -302 ; disable 'Register in operand not in bank 0' warningRES_VECT CODE 0x0000 ; processor reset vectorGOTO Start ; go to beginning of programMAIN_PROG CODE ; let linker place main programStart:BANKSEL LATA ; Data LatchCLRF LATA ; clearedBANKSEL TRISA ;MOVLW B'011111' ; Set RA<5> as output - only pin without ADCMOVWF TRISA ; and set RA<4:0> as inputs; fortunately FVRCON and LATA are in the same bank,; so don't need to mess with FVR/INDF!BANKSEL LATA ; *** correction by 1001 ***Loop:BTFSS FVRCON,FVRRDY ; Copy FVRRDY to RA5BCF LATA, 5BTFSC FVRCON,FVRRDYBSF LATA, 5GOTO Loop ; loop foreverENDYou'll need either MPLAB v8.92 or MPLAB X v<=5.35 as MPASM support was dropped from later MPLAB X versions.Connect a 10K pullup to /MCLR and the LED (+ series resistor) from RA5 to Vss.Alternatively if you are sticking with XC8 + MCC, turn off the FVR with:Code:FVRCONbits.FVREN=0;before your loop, and use a real LED, not the debugger!Edit: Code fixed, see below.

author: 1001
author_rank: Contributor
timestamp: March 27, 2021, 02:52:03 pm
content: Thanks a lot Ian, I tested your code and led is on so FVRRDY is 1. I had to addCode:BANKSEL LATAbeforeCode:LOOP:to select the right bank to get working yor firmware.Now I can say with confidence that I have purchased some PIC12F1840 with a wrong Device ID, It could have been worse

author: Ian.M
author_rank: Super Contributor
timestamp: March 27, 2021, 04:11:33 pm
content: Whoops - sorry I missed the BANKSEL! Unfortunately I didn't have any PIC12F1840 here to test it properly.It sounds like its time to raise a support ticket with Microchip, and say you've got some possible fakes, and ask if they would like one to investigate. They probably wont be interested if they've already had several reports of them, but if fake PIC12F1840 chips are a new thing they may well want to investigate further.

author: 1001
author_rank: Contributor
timestamp: March 27, 2021, 04:22:29 pm
content: I am not sure if this is a fake mcu or not, FVRRDY is always 1 as in PIC12F1840, just device ID is wrong. Are our chineese friends on aliexpress able to change permanently 1 bit of SFR register of these mcu?!? could be a mistake of microchip on few lot of this mcu?

author: Ian.M
author_rank: Super Contributor
timestamp: March 27, 2021, 04:28:05 pm
content: Many older 8 bit PICs don't have the factory set words in the memory area that holds the device ID, revision, factory calibration data, and user CONFIG and ID words, fully locked down. You could corrupt all sorts of stuff if the programmer glitched while erasing a device, or a 3rd party programmer had a bad device definition file. I *DON'T* know if that's the case for the PIC12(L)F1840. Another possibility is that its a 100% pure Chinesium clone fake.

author: 1001
author_rank: Contributor
timestamp: March 27, 2021, 04:39:06 pm
content: QuoteI'm dying of laughter

author: DavidAlfa
author_rank: Super Contributor
timestamp: March 27, 2021, 11:56:11 pm
content: We're waiting for you to decap those and compare the dies with genuine onesAnyways, that mcu is a bit old. Consider getting a newer design, it will be cheaper and better.Some time ago I tried the newer PIC16F18323 for a very space-constrained project (TSSOP-14), they were great.If you can afford the space for a 14-pin package, the PIC16F18326 has 28KB flash, 2KB RAM while costing less than the 12F1840.Also newer and better peripherals. I got them pretty cheap in RS. In fact in Aliexpress they were way more expensive!

author: 1001
author_rank: Contributor
timestamp: April 02, 2021, 08:35:52 pm
content: The upper surface should be the same in appearance as the lower one, instead it seems to have been treated with sandpaper or laser ablation and has grooves that can be highlighted with grazing light. the other microcontrollers are for comparison only and come from an authorized dealer. Also, the marking is not aligned with the case. what do you think? seems to be a clear case of a Chinesium fake.

author: exe
author_rank: Unknown
timestamp: April 03, 2021, 07:20:17 pm
content: It seems sanded to me. This still doesn't answer what's inside

author: DavidAlfa
author_rank: Super Contributor
timestamp: April 03, 2021, 09:32:33 pm
content: PIC12/16 architecture is very simple, 20+ years old, there are a lot of similar MCUs in the market with almost same instruction set, registers, etc, no surprises here.