Author Topic: Weird PIC12F1840  (Read 3038 times)

0 Members and 1 Guest are viewing this topic.

Offline 1001Topic starter

  • Contributor
  • Posts: 29
  • Country: it
Weird PIC12F1840
« on: March 24, 2021, 12:18:30 pm »
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?
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 13056
Re: Weird PIC12F1840
« Reply #1 on: March 24, 2021, 12:48:20 pm »
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.  See PIC12(L)F1840 datasheet section 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.
« Last Edit: March 24, 2021, 12:50:10 pm by Ian.M »
 
The following users thanked this post: 1001

Offline 1001Topic starter

  • Contributor
  • Posts: 29
  • Country: it
Re: Weird PIC12F1840
« Reply #2 on: March 27, 2021, 12:16:27 pm »
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.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 13056
Re: Weird PIC12F1840
« Reply #3 on: March 27, 2021, 01:01:40 pm »
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: [Select]
#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_ON

    errorlevel -302 ; disable 'Register in operand not in bank 0' warning
 
RES_VECT  CODE    0x0000            ; processor reset vector
    GOTO    Start                   ; go to beginning of program

MAIN_PROG CODE                      ; let linker place main program

Start:
    BANKSEL LATA ; Data Latch
    CLRF LATA ; cleared
    BANKSEL TRISA ;
    MOVLW B'011111' ; Set RA<5> as output - only pin without ADC
    MOVWF 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 RA5
    BCF LATA, 5
    BTFSC FVRCON,FVRRDY
    BSF LATA, 5
    GOTO Loop ; loop forever

    END
You'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: [Select]
FVRCONbits.FVREN=0;before your loop, and use a real LED, not the debugger!

Edit: Code fixed, see below.
« Last Edit: March 27, 2021, 04:13:37 pm by Ian.M »
 

Offline 1001Topic starter

  • Contributor
  • Posts: 29
  • Country: it
Re: Weird PIC12F1840
« Reply #4 on: March 27, 2021, 02:52:03 pm »
Thanks a lot Ian, I tested your code and led is on so FVRRDY is 1. I had to add
Code: [Select]
BANKSEL LATAbefore
Code: [Select]
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   :-DD
« Last Edit: March 27, 2021, 03:14:25 pm by 1001 »
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 13056
Re: Weird PIC12F1840
« Reply #5 on: March 27, 2021, 04:11:33 pm »
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.
 

Offline 1001Topic starter

  • Contributor
  • Posts: 29
  • Country: it
Re: Weird PIC12F1840
« Reply #6 on: March 27, 2021, 04:22:29 pm »
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?
« Last Edit: March 27, 2021, 04:25:17 pm by 1001 »
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 13056
Re: Weird PIC12F1840
« Reply #7 on: March 27, 2021, 04:28:05 pm »
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.
 

Offline 1001Topic starter

  • Contributor
  • Posts: 29
  • Country: it
Re: Weird PIC12F1840
« Reply #8 on: March 27, 2021, 04:39:06 pm »
Quote
100% pure Chinesium clone fake
I'm dying of laughter  :-DD
 

Online DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6218
  • Country: es
Re: Weird PIC12F1840
« Reply #9 on: March 27, 2021, 11:56:11 pm »
We're waiting for you to decap those and compare the dies with genuine ones  :D
Anyways, 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!
« Last Edit: March 28, 2021, 12:01:08 am 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: 1001

Offline 1001Topic starter

  • Contributor
  • Posts: 29
  • Country: it
Re: Weird PIC12F1840
« Reply #10 on: April 02, 2021, 08:35:52 pm »
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.
 

Online exe

  • Supporter
  • ****
  • Posts: 2611
  • Country: nl
  • self-educated hobbyist
Re: Weird PIC12F1840
« Reply #11 on: April 03, 2021, 07:20:17 pm »
It seems sanded to me. This still doesn't answer what's inside :)
 
The following users thanked this post: 1001

Online DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6218
  • Country: es
Re: Weird PIC12F1840
« Reply #12 on: April 03, 2021, 09:32:33 pm »
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.
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 
The following users thanked this post: 1001


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf