No funciona proyecto con pic16F883
Moderator: Benj
No funciona proyecto con pic16F883
Hello,
I have a project done and apparently it works as I want in the Flowcode simulator itself. Once this has been verified, the next thing I have done is obtain the hexadecimal file.
The compiler seems to have worked correctly, because in the end I get the hex file.
Then I save the hex file in the pic and it doesn't work.
When configuring and indicating that everything is fine, the texts of the attached file appear to me.
Can you tell me and/or help me what can happen?
Thanks in advance
F.
I have a project done and apparently it works as I want in the Flowcode simulator itself. Once this has been verified, the next thing I have done is obtain the hexadecimal file.
The compiler seems to have worked correctly, because in the end I get the hex file.
Then I save the hex file in the pic and it doesn't work.
When configuring and indicating that everything is fine, the texts of the attached file appear to me.
Can you tell me and/or help me what can happen?
Thanks in advance
F.
- Attachments
-
- Contador_pulsos_V0_22_C.msg.txt
- (3.08 KiB) Downloaded 456 times
-
- Valued Contributor
- Posts: 1208
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
Re: No funciona proyecto con pic16F883
Hi
Looks like you have a function that calls itself either directly or indirectly.
Please post your code (the..fcfx file) and someone will take a look...
Martin
Looks like you have a function that calls itself either directly or indirectly.
Please post your code (the..fcfx file) and someone will take a look...
Martin
Re: No funciona proyecto con pic16F883
It's weird because I don't think there is anything nested.
Sorry for forgetting.
I thought I had attached it too.
Attached the fcfx file
F.
Sorry for forgetting.
I thought I had attached it too.
Attached the fcfx file
F.
- Attachments
-
- Contador_pulsos_V0_22_C.fcfx
- (61.08 KiB) Downloaded 385 times
-
- Valued Contributor
- Posts: 1208
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
Re: No funciona proyecto con pic16F883
I think one problem is that the interrupt handler (Cuentar_Grabar) calls Multiplexado. This will cause 'issues' if an interrupt occurs whist the code is in Multiplexado - although the compiler has attempted to negate this by duplicating the function - I think it will still cause things to 'break'.
Calling Multiplexado at 122Hz - may cause a lockup (how long does Clear/Show digit take) - the interrupt handler needs to be kept short and quick...
There also seems to be a very limited stack size on the MCU you are using - an issue that doesn't affect simulation (an interesting feature -- maybe it should?)
Martin
Calling Multiplexado at 122Hz - may cause a lockup (how long does Clear/Show digit take) - the interrupt handler needs to be kept short and quick...
There also seems to be a very limited stack size on the MCU you are using - an issue that doesn't affect simulation (an interesting feature -- maybe it should?)
Martin
-
- Valued Contributor
- Posts: 1208
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
Re: No funciona proyecto con pic16F883
Next problem.
There is a call to multiplexado in entrada_paros.
This won't work in an interrupt routine (imagine the problem if the display is updating when an interrupt occurs)
Can I also suggest using an array for the individual digits...
Martin
There is a call to multiplexado in entrada_paros.
This won't work in an interrupt routine (imagine the problem if the display is updating when an interrupt occurs)
Can I also suggest using an array for the individual digits...
Martin
Re: No funciona proyecto con pic16F883
Thanks Martin for the responses.
I have deactivated multiplexado the pulse input icon and although ag is now seen on the displays, the numbers still do not appear correctly and it is not appreciated that the program works as it should.
When compiling I still get a series of messages:
using updated 32-bit floating-point libraries; improved accuracy might increase code size
C:\PROGRA~2\FLOWCO~1\COMPIL~1\pic\sources\common\lbdiv.c: 4: non-reentrant function "___lbdiv" appears in multiple call graphs and has been duplicated by the compiler
C:\PROGRA~2\FLOWCO~1\COMPIL~1\pic\sources\common\lbmod.c: 4: non-reentrant function "___lbmod" appears in multiple call graphs and has been duplicated by the compiler
C:\PROGRA~2\FLOWCO~1\COMPIL~1\pic\sources\common\lwdiv.c: 6: non-reentrant function "___lwdiv" appears in multiple call graphs and has been duplicated by the compiler
C:\PROGRA~2\FLOWCO~1\COMPIL~1\pic\sources\common\lwmod.c: 6: non-reentrant function "___lwmod" appears in multiple call graphs and has been duplicated by the compiler
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\internals.c: 77: (1090) variable "_FCI_TMP_INT" is not used (warning)
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\internals.c: 76: (1090) variable "_FCI_TMP_STR" is not used (warning)
Is there anything else I can do to fix the problem?
Thanks in advance
fermin
I have deactivated multiplexado the pulse input icon and although ag is now seen on the displays, the numbers still do not appear correctly and it is not appreciated that the program works as it should.
When compiling I still get a series of messages:
using updated 32-bit floating-point libraries; improved accuracy might increase code size
C:\PROGRA~2\FLOWCO~1\COMPIL~1\pic\sources\common\lbdiv.c: 4: non-reentrant function "___lbdiv" appears in multiple call graphs and has been duplicated by the compiler
C:\PROGRA~2\FLOWCO~1\COMPIL~1\pic\sources\common\lbmod.c: 4: non-reentrant function "___lbmod" appears in multiple call graphs and has been duplicated by the compiler
C:\PROGRA~2\FLOWCO~1\COMPIL~1\pic\sources\common\lwdiv.c: 6: non-reentrant function "___lwdiv" appears in multiple call graphs and has been duplicated by the compiler
C:\PROGRA~2\FLOWCO~1\COMPIL~1\pic\sources\common\lwmod.c: 6: non-reentrant function "___lwmod" appears in multiple call graphs and has been duplicated by the compiler
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\internals.c: 77: (1090) variable "_FCI_TMP_INT" is not used (warning)
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\internals.c: 76: (1090) variable "_FCI_TMP_STR" is not used (warning)
Is there anything else I can do to fix the problem?
Thanks in advance
fermin
-
- Valued Contributor
- Posts: 1208
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
Re: No funciona proyecto con pic16F883
The warning about non re-entrant function means that a function may occur in an interrupt - but probably shouldn't (the result will be incorrect if an interrupt occurs whilst the code is doing a division and the interrupt handler uses division for example) So you should remove calls to divide and mod (/ and %) operators in interrupt handlers.
You can ignore the variable not used warnings...
What are you trying to achieve? Does the code do anything on hardware (light some or just wrong segments)
Martin
You can ignore the variable not used warnings...
What are you trying to achieve? Does the code do anything on hardware (light some or just wrong segments)
Martin
Re: No funciona proyecto con pic16F883
Again thank you very much for the answer.
He explained it to me well and I understood correctly.
I have removed the divider block from the pulse input interrupt.
I have compiled it and no indication appears anymore.
Tomorrow I record the pic and try.
I will indicate the result, although now I have observed in the simulator that there are times that I have to press each of the buttons several times for them to react. Ok I'll check it out
What I intend is to make a descending counter once the discount value has been chosen. This will be for pulses on RB0.
Fermin
He explained it to me well and I understood correctly.
I have removed the divider block from the pulse input interrupt.
I have compiled it and no indication appears anymore.
Tomorrow I record the pic and try.
I will indicate the result, although now I have observed in the simulator that there are times that I have to press each of the buttons several times for them to react. Ok I'll check it out
What I intend is to make a descending counter once the discount value has been chosen. This will be for pulses on RB0.
Fermin
-
- Valued Contributor
- Posts: 2045
- Joined: Wed Aug 27, 2008 10:31 pm
- Location: Netherlands
- Has thanked: 553 times
- Been thanked: 1081 times
Re: No funciona proyecto con pic16F883
According to the compiler warnings you are using floating point variables. Do you need floating point or would (long) integers be sufficient?
“Integrity is doing the right thing, even when no one is watching.”
― C.S. Lewis
― C.S. Lewis
-
- Valued Contributor
- Posts: 1208
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
Re: No funciona proyecto con pic16F883
Take a look at the sample code for the 7seg display (at https://www.flowcode.co.uk/wiki/index.p ... _(Segment))
This uses an interrupt to handle the 'switching' between digits. Note that this can either occur in an interrupt or in the main loop (not both)
I would use something like this with a variable 'count' - that is decremented by a 1s interrupt handler to handle the 'countdown'.
Similarly for 'setting' the number - let the interrupt handler take care of the display (so your code just needs to set 'count'). With buttons you have to watch for 'bounce' (multiple signals caused by the contacts on press) - either use the switch macros to read their state or add a check in code for this (or add a capacitor)
Martin
This uses an interrupt to handle the 'switching' between digits. Note that this can either occur in an interrupt or in the main loop (not both)
I would use something like this with a variable 'count' - that is decremented by a 1s interrupt handler to handle the 'countdown'.
Similarly for 'setting' the number - let the interrupt handler take care of the display (so your code just needs to set 'count'). With buttons you have to watch for 'bounce' (multiple signals caused by the contacts on press) - either use the switch macros to read their state or add a check in code for this (or add a capacitor)
Martin
Re: No funciona proyecto con pic16F883
Thanks, Martin.
Before your last answer, I had already reviewed an example from the folwcode wiki and seen how the multiplexing is done.
I have adapted it to my project and when testing I found that our displays blinked very quickly and the values to be represented were barely distinguishable.
I assumed that it was due to the multiplexing frequency and I was going to raise it until I found the most suitable one.
But having seen the example that you have attached, I think the frequency is 250Hz, so tomorrow I will try directly with that frequency.
Once this problem is resolved, I would review the rest of the program and I am sure that I will have some more questions that I hope if not resolved if I will consult again.
Before your last answer, I had already reviewed an example from the folwcode wiki and seen how the multiplexing is done.
I have adapted it to my project and when testing I found that our displays blinked very quickly and the values to be represented were barely distinguishable.
I assumed that it was due to the multiplexing frequency and I was going to raise it until I found the most suitable one.
But having seen the example that you have attached, I think the frequency is 250Hz, so tomorrow I will try directly with that frequency.
Once this problem is resolved, I would review the rest of the program and I am sure that I will have some more questions that I hope if not resolved if I will consult again.
Re: No funciona proyecto con pic16F883
After the test has been done by increasing the frequency, now the displays can be seen without blinking, but I see a couple of defects that I don't understand why it's happening:
1º the value of the units digit is always reflected in the tens digit.
2º In addition to the above, the segments that should not light up when representing a number also appear lit, although in a more dim way.
Any advice to solve these problems?
I attach the project as it is now. With the multiplexing routine copied from an example on the Flowode wiki.
Once these problems have been solved, I would check the operation of the buttons, although the start-up (B4) and reset (B5) ones do work well.
F.
1º the value of the units digit is always reflected in the tens digit.
2º In addition to the above, the segments that should not light up when representing a number also appear lit, although in a more dim way.
Any advice to solve these problems?
I attach the project as it is now. With the multiplexing routine copied from an example on the Flowode wiki.
Once these problems have been solved, I would check the operation of the buttons, although the start-up (B4) and reset (B5) ones do work well.
F.
- Attachments
-
- Contador_pulsos_V0_23.fcfx
- (63.9 KiB) Downloaded 408 times
Re: No funciona proyecto con pic16F883
Hello,
I have continued trying to find the defect described in the previous post and I don't see what could be the cause.
I have reduced the program to the maximum so that the status of a button is read and that the value increases with each push and is displayed in one of the 7-segment digits.
Ignoring the problem that may exist with bounces, the example detects when a + pulse is received at B3 by increasing the value of the hundreds digit by one.
In the simulator it works well, but in reality the value to be displayed in the hundreds digit is always reflected in the tens digit. The same happens whatever digits are chosen. Whether they are hundreds, tens or units
But the values are not very well distinguished either because in addition to lighting up the segments that show the value, the rest of the segments that should not light up also light up, although they do so more dimly.
For example, if the value 500 is required to be represented on the displays, it actually appears as 550, but with the "b and e" segments also lit more dimly, so it actually appears as 880. Any idea how to fix this effect?
Attached the example file and the simplified scheme made by hand.
Thanks in advance
I have continued trying to find the defect described in the previous post and I don't see what could be the cause.
I have reduced the program to the maximum so that the status of a button is read and that the value increases with each push and is displayed in one of the 7-segment digits.
Ignoring the problem that may exist with bounces, the example detects when a + pulse is received at B3 by increasing the value of the hundreds digit by one.
In the simulator it works well, but in reality the value to be displayed in the hundreds digit is always reflected in the tens digit. The same happens whatever digits are chosen. Whether they are hundreds, tens or units
But the values are not very well distinguished either because in addition to lighting up the segments that show the value, the rest of the segments that should not light up also light up, although they do so more dimly.
For example, if the value 500 is required to be represented on the displays, it actually appears as 550, but with the "b and e" segments also lit more dimly, so it actually appears as 880. Any idea how to fix this effect?
Attached the example file and the simplified scheme made by hand.
Thanks in advance
- Attachments
-
- CONTADOR DE PULSOS (esquema electrico).pdf
- (1.52 MiB) Downloaded 367 times
-
- PRUEBA_C.fcfx
- (33.28 KiB) Downloaded 431 times
-
- Valued Contributor
- Posts: 1208
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
Re: No funciona proyecto con pic16F883
Just to try and see where the problem lies: Please can you try this - I did a minimal display routine (based on yours - I really just removed the code to modify the values) - but I'd be interested to know if this displays correctly on hardware.
If the clock is correct etc it should countdown at ~1s intervals. If not then we need to dig deeper into the display routine.
Martin
If the clock is correct etc it should countdown at ~1s intervals. If not then we need to dig deeper into the display routine.
Martin
Re: No funciona proyecto con pic16F883
Checked and the answer is disastrous. Nothing more than illegible characters is appreciated.
Can a small video be attached to the forum so I can see the result?
The multiplexing is collected from an example of the Flowcode wiki
F
Can a small video be attached to the forum so I can see the result?
The multiplexing is collected from an example of the Flowcode wiki
F
-
- Valued Contributor
- Posts: 1208
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
Re: No funciona proyecto con pic16F883
That's interesting - and tells us a fair bit.. How about if you remove the timer interrupt that counts down?
I have a couple of the 7 segment displays - I'll try wiring them up and getting them going. Will have to be a different MCU though..
Martin
I have a couple of the 7 segment displays - I'll try wiring them up and getting them going. Will have to be a different MCU though..
Martin
Re: No funciona proyecto con pic16F883
Martín,
En el ejemplo que has mandado, no hay temporización.
El decremento se realiza por la interrupción y el múltiplexado también se hace por medio de otra interrupcion.
Lo que e yo he mandado es básicamente el ejemplo que hay en la wiki de Flowcode no recuerdo el nombre pero está en la ayuda del funcionamiento de los 7 segmentos. Allí es con incremento y yo necesito decremento.
Decirte que el hardware básicamente está funcionando pues con otros programas realizados en C, Niple, el funcionamiento es ok.
Me hubiera gustado adjuntar el vídeo, no es muy largo pero ocupa mucho. No obstante si me dice dónde puedo enviárselo, se lo mando.
F.
En el ejemplo que has mandado, no hay temporización.
El decremento se realiza por la interrupción y el múltiplexado también se hace por medio de otra interrupcion.
Lo que e yo he mandado es básicamente el ejemplo que hay en la wiki de Flowcode no recuerdo el nombre pero está en la ayuda del funcionamiento de los 7 segmentos. Allí es con incremento y yo necesito decremento.
Decirte que el hardware básicamente está funcionando pues con otros programas realizados en C, Niple, el funcionamiento es ok.
Me hubiera gustado adjuntar el vídeo, no es muy largo pero ocupa mucho. No obstante si me dice dónde puedo enviárselo, se lo mando.
F.
Re: No funciona proyecto con pic16F883
O si me manda una dirección de mail, lo pongo en mi Drive para que lo descargué.
Le mando el link de descarga y puede chequear todo mejor.
Creo que en 1 hora lo subo y le mando el link por mensaje privado aquí en el foro.
Le mando el link de descarga y puede chequear todo mejor.
Creo que en 1 hora lo subo y le mando el link por mensaje privado aquí en el foro.
-
- Valued Contributor
- Posts: 1208
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
Re: No funciona proyecto con pic16F883
In the example you have sent, there is no timing.
The decrement is done by the interrupt and the multiplexing is also done by another interrupt.
What I have sent is basically the example that is in the Flowcode wiki I don't remember the name but it is in the help of the operation of the 7 segments. There is with increase and I need decrease.
Tell you that the hardware is basically working because with other programs made in C, Niple, the operation is ok.
I would have liked to attach the video, it is not very long but it takes up a lot. However, if you tell me where I can send it to you, I'll send it to you.
Thanks to Google translate
It's true - I did all the timing with an interrupt - one route is to zip the video. Another is Youtube... I can pm you my email...
The decrement is done by the interrupt and the multiplexing is also done by another interrupt.
What I have sent is basically the example that is in the Flowcode wiki I don't remember the name but it is in the help of the operation of the 7 segments. There is with increase and I need decrease.
Tell you that the hardware is basically working because with other programs made in C, Niple, the operation is ok.
I would have liked to attach the video, it is not very long but it takes up a lot. However, if you tell me where I can send it to you, I'll send it to you.
Thanks to Google translate
It's true - I did all the timing with an interrupt - one route is to zip the video. Another is Youtube... I can pm you my email...
-
- Valued Contributor
- Posts: 1208
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
Re: No funciona proyecto con pic16F883
In the clip the digit does appear to be 'counting' down. With lots of extra 'guff' displayed.
I got three digits working with an Arduino - using a 4 digit display (hardware) but treating as 3 individual digits (I ignored the left hand digit)
I used a 1k resistor to each of the digit select pins (although for even brightness it probably should have been a resistor on each segment...)
I 'numbered' the digits 0 -2 (units 0, 10s 1 and 100s 2) - so (in multiplex) if currently displaying units - clear units (which clears the common pin) - and display 10s. If displaying 10s (digit 1) - clear 10s and display 100s. Displaying 100s (2) - clear 100s and display units..
Sorry - the pins are all for Arduino - my setup is not so neat
Just lots of jumpers and 3 resistors...
Martin
I got three digits working with an Arduino - using a 4 digit display (hardware) but treating as 3 individual digits (I ignored the left hand digit)
I used a 1k resistor to each of the digit select pins (although for even brightness it probably should have been a resistor on each segment...)
I 'numbered' the digits 0 -2 (units 0, 10s 1 and 100s 2) - so (in multiplex) if currently displaying units - clear units (which clears the common pin) - and display 10s. If displaying 10s (digit 1) - clear 10s and display 100s. Displaying 100s (2) - clear 100s and display units..
Sorry - the pins are all for Arduino - my setup is not so neat

Martin