Home
Prox / RFID
Verichips
Ladder Logic
[interfacing] †
Tube Joints
Key Code From Photo
SolveSpace (3d CAD)
SketchFlat (2d CAD)
Photographs
Miscellany
Resume / Consulting
Contact Me

LDmicro Forum - problema con pic16f876a

(you are viewing a thread; or go back to list of threads)

problema con pic16f876a (by claudio calcagno)
Hello, I have a problem with pic 16f876a that with pic 16f877a, practically the same defect, in the program all the I/O were used with the simulator is all ok but after programming in the pics some I/O do not work, please could you give me a hand?
thank you.
Sun Oct 10 2021, 09:59:28
(no subject) (by José)
Hi Claudio

Can you post your ld file to have an idea of the pb ?

José
Sun Oct 10 2021, 14:24:07
(no subject) (by claudio calcagno)
Hello, in this case the problem is has branches 8-9-10-11, X3=Y3, X4=Y9-Y4, thank you very much.
Mon Oct 11 2021, 01:59:36, download attachment GSM3bis.ld
(no subject) (by José)
OK Claudio

I have had a look at your ld program.

In your READ_ADC instructions for AAN0 (RA0) and AAN1 (RA1) you have left the REFS field at its default value of 0.
It can inpact other A/D pins like RA2 (X3), RA3 (X4) and RA5 (Y9) because it indicates which ADC pins are in use (default 0 = all A/D pins).

So you should have a look at the PIC16F87X datasheet (A/D chapter, register ADCON1) to get the right value for REFS to be written in PCFG0-PCFG3 bits.

I have had a look, but I don't see a configuration matching your program because you must have AN0 and AN1 as 'A' and the others as 'D' with references VREF+/- at Vdd/Vss (should be 2/0 in the last column of the PCFG table)
The closest solution is 3/0 (REFS= 0100b = 0x04) but it involves RA3 (X4) !
Have a look at attached picture to undestand.

I think you'll have to modify your pin assignment or use a PIC16F77 with more pins...

The pb doesn't appear in simulation because it probably doesn't use the REFS field.

Best regards
José

PS:
- which version of ldmicro are you using ?
- do you use external libraries ?
Mon Oct 11 2021, 03:35:25, download attachment Refs.jpg
(no subject) (by MGP)
https://github.com/LDmicro/LDmicro/wiki/ADC-Voltage-Reference

For general use of LDmicro you don't need to change the REFS field, I never use that field.

The program looks good to me, just beware that RA4 has an open drain output.

There is probably a hardware error, do you have a schematic?
Mon Oct 11 2021, 04:15:52
(no subject) (by Calubert)
Put these bits (0x2F42) and change the Timer0 = 0, the = 1 always comes by default, I think I see that many young people in the forum do not see it but it is put in the manual. This must be placed in the Micro configuration window
Tell me if it worked for you (Thanks Calubert)

Pon Estos bit (0x2F42) y cambia el Timer0 =0 biene por defecto siempre el=1, creo que esto veo que muchos jóvenes en el foro no lo ven pero esta puesto en el manual.
Mon Oct 11 2021, 04:56:11
(no subject) (by Paulino Calubert)
In LDMicro:
The essential functions for it to work:
setting:
1st is essential when choosing Microcontroller, also modifying Timer0 = 0 (Timer0 = 1 comes by default).
2º Put in the bit box (0x2F42 Note in PIC) these always work for me, open thousands of programs.

what if this is not filled; in simulations everything works in sight but really, since we don't have a configuration bit since the box is visible, the microprocessor will work with errors, Note; in proteus by default it already places a series of bits (and it works as it happens with LCMicro since the simulation happens to be by PC)

Note: this paragraph refers to compiling and saving the Microcontroller.
Please if anyone sees that this writing is not correct let me know.


En LDMicro:
Las funciones esenciales para que funcione:
configuración:
1º es esencial al elegir Microcontrolador, también modificar Timer0=0 (viene por defecto Timer0 =1).
2º Colocar en la casilla bit (0x2F42 Nota en PIC) estos a mi me funciona siempre abre hecho miles de programas.

que pasa si esto no se rellena; en simulaciones funciona todo a la vista pero realmente, como no tenemos bit de configuración ya que la casilla se ve bacía el microprocesador funcionara con errores, Nota; en proteus por defecto ya coloca una serie de bit ( y funciona como pasa con LCMicro ya que la simulación pasa a ser por PC)

Nota : este párrafo se refiere al copilar y grabar el Microcontrolador.
Por Favor si alguien ve que este escrito no es correcto haganmelo saber.
Mon Oct 11 2021, 05:26:52
(no subject) (by José)
Dear MGP


When using external libraries, REFS field may be important...
And maybe without external libraries too.

It seems all the more relevant as the pins with pbs exactly match those used by A/D converter...

BR
José
Mon Oct 11 2021, 06:02:39
(no subject) (by MGP)
@José
I always assume that no external libraries are used unless stated.
In this case it is certainly not necessary to change the REFS field, you can mix all inputs between input/analog or outputs without any problems.
I don't know about AVRs, I don't use them and don't use external libraries, I'm an original LDmicro user ;)


@Paulino
The use of Timer0/1/2 is only important with PWM.
if you make a mistake ldmicro will give an error.

https://github.com/LDmicro/LDmicro/wiki/LDmicro-PWM

Configword: 2F42 and 3F72 will both work well with the Pickit2/3, I always use 3F72.

----------------

For the newbies among us, LDmicro works perfectly as it exists now, don't look too far, usually it's a selfmade hardware failure if the ldmicro simulation works well.
Mon Oct 11 2021, 07:01:56
(no subject) (by paulino Calubert)
OK perfect, but I impose that the bits must be set if it will not give errors such as timer0 = 0 several that I did not know that it was only with PWM if you want to use YPlcCicledDty I think that timert0 = 0 should be set I would propose that they always set the timert0 = 0 as necessary.
I am not a great expert and every day I learn about industrial PLCs.

OK perfecto, pero impongo que los bit se deben colocar si no dará erratas como timer0 =0 varios que ignoraba que fuera solo con PWM si se quiere usar YPlcCicledDty creo que se debe de colocar timert0 =0 yo propondría que colocaran el timert0=0 siempre que sea necesario.
no soy un gran experto y cada dia aprendo sobre PLC industriales.
Mon Oct 11 2021, 07:26:33
(no subject) (by MGP)
I suppose LDmicro will show a warning when using Timer0/1 in combination with YplcCycleDuty if it's not set right.

Most difficulties in LDmicro are caused by the wrong setting of the pullup resistors and config words and sometimes I forget that.

Arduino and AVR are controllers i don't use, that's why i will never answer when talking about those controllers.

I used to use a 16F876a a lot, now it's usually 16F1840 and 16F1827 and sometimes a 16F886 because they have an internal oscillator.
Mon Oct 11 2021, 09:40:16
(no subject) (by paulino Calubert)
(por MGP) Right, I usually play with ESP8266 and external libraries.
saludos Paulino Calubert
Mon Oct 11 2021, 10:46:06
Post a reply to this comment:
Your Name:
Your Email:
Subject:
(no HTML tags; use plain text, and hit Enter for a line break)
Attached file (if you want, 5 MB max):