I wonder if it would be possible for you to have a quick look at this short program as attached for the beginnings of a Power meter and see if there is any reason for this program to hang....Many Thanks
DimP1vasBIT'dim a BIT... not sure whyDimP2iasBIT'dim a BIT... not sure why
...
DirPortA.3in'set directionDirPortA.2in'set directiondirPortE.3in'set directionP1v=PortA.3'set p1v to the state of the port as this pointP2i=PortA.2'set p2i to the state of the port as this pointDoUntilP1v=0'test p1v.. never changes..LoopDoUntilP1v=1'test p1v.. never changes..LoopDoUntilP2i=1'test p2i.. never changes..aa=aa+1Loop
P1V, p2i were dim'ed as bits, and then you set that bit to the state of a port.
New code
#Define P1v PortA.3
#Define P2i PortA.2
Dir P1v in
Dir p2i in
p1v and p2i are constants addressing the two ports, then, using these constants set the port DIRection, then
Thanks for your comment BILL.
what i am going to try is
ANSELA.2=0
ANSELA.3=0
to enable the digital input buffer on pins RA2 and RA3 these pins default=1 to enable ADC
Since by default ADON=0 for disable ADC
PMD2.ADCMD=0 to Disable ADC module .
Can you please tell me what amplitude in Volts RA6 FOSC/4 subject to INT107 should be .Any reason why I am not getting 5Vp-p.I am getting +_100mV
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The amplitude of clockout on RA6 will vary, depending upon the frequency. The higher the system clock, the lower the amplitude. 100mv is just about right for FOSC =64 Mhz.
It is not necessary change the ANSELA bits as these are already set to the proper default values via "Initsys". Initsys is a subroutine that runs when the chip is started or reset. These setting can viewed by opening the ASM file ( after compiling your code). PMD2 defaults to 0 at POR. and remains at 0 unless intentionally disabled.
My questions are:
1) Why do you think you need to change these registers?
2) What is the actual issue?
Last edit: William Roth 2021-07-11
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Jeff's latest code attached here - No explanation by Jeff as to why it was posted.
@Jeff
If you need help please describe the problem. Simply posting code tells us very little.
Also, I asked you two questions in my post above but you seemed to ignore them. If you want good help it is important to provide feedback to those taking the time to help.
Thank you for your comments Mr Roth. What I found was that the 1st program I posted was hanging , after being verified as correctly programmed, when I ran the chip wired to the LCD Nothing printed.wrt the Print(s) LCD at the end of the program and I have another program which prints when tested which even has #CONFIG DEBUG=ON What I suspected was that ANSELA.2 and ANSELA.3 were at their default value of high disabling the digital input buffer.Ignorance of the procedure you mentioned above wrt to the ASM file. So I have included the 2 statements ANSELA.2=0 ANSELA.3=0 to enable the dig input buffer on RA2 and RA3.
So I sent you the new short program again for which i figured that an expert like you could glance and see if there were any mistakes without a problem.There are a few comments at the top to describe the action.Anything outstanding in respect of a glance and a mistake here in the new short program?
If ANSELA.2 and ANSELA.3 have been cleared as you say they have then I really have a problem.
Thanks very much for your help much appreciated .
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You still have not told us what the actual problem is given the the latest code.
Does the program still "hang"?
Does the LCD Display initialize and correctly display characters? Yes or No?
Most LCD displays require 5.0V. A few require 3.3V
What LCD Display are you using . Brand/ Model
Why are you using LCD RW ? Do you need to read the LCD memory ?
Why did you set the LCD Pin Directions with DIR PORTC OUT ( this is done automatically via the LCD library )
Why do you have CLKOUT enabled on RA6 with #Config INTIO7 ?
Why have you set PORTE. 3 as an input ?
It seems to me that you have made a lot of incorrect assumptions that have lead to unnecessary code.
If it were me I would start from scratch and first get the LCD display working
with minimal code. Then, confident that the the LCD is working correctly, add in
sections of code one at a time, verifying as you go.
For Reference: When a GCB program starts. ALL ANSEL registers are Cleared to 0 and ALL Pins are set as digital inputs. This is the real default.
So first tell me does the LCD Display work? Yes or No?
Last edit: William Roth 2021-07-16
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I wonder if it would be possible for you to have a quick look at this short program as attached for the beginnings of a Power meter and see if there is any reason for this program to hang....Many Thanks
Sure... can you define hanging? during compiling or when testing the code on real silicon?
Sure... can you define hanging? during compiling or when testing the code on real silicon?
You have
bit
aliases and constants mixed up.Old code with comments
P1V, p2i were dim'ed as bits, and then you set that bit to the state of a port.
New code
p1v and p2i are constants addressing the two ports, then, using these constants set the port DIRection, then
Last edit: Anobium 2021-07-08
Also,
~~~
Do Until P2i = 1
aa =aa+ 1
Loop
DEFINE USE_Timer0 false
DEFINE USE_Timer1 true
DEFINE USE_Timer2 false
DEFINE USE_Timer3 false
DEFINE USE_Timer4 false
DEFINE USE_Timer5 false
DEFINE USE_Timer6 false
#Define P1v LATA.3
#Define P2i LATA.2
~~~
:-)
I see that Debug = ON in the config settings. This should be OFF for normal operation.
Bill
Thanks for your comment BILL.
what i am going to try is
ANSELA.2=0
ANSELA.3=0
to enable the digital input buffer on pins RA2 and RA3 these pins default=1 to enable ADC
Since by default ADON=0 for disable ADC
PMD2.ADCMD=0 to Disable ADC module .
Can you please tell me what amplitude in Volts RA6 FOSC/4 subject to INT107 should be .Any reason why I am not getting 5Vp-p.I am getting +_100mV
The amplitude of clockout on RA6 will vary, depending upon the frequency. The higher the system clock, the lower the amplitude. 100mv is just about right for FOSC =64 Mhz.
A guideline:
It is not necessary change the ANSELA bits as these are already set to the proper default values via "Initsys". Initsys is a subroutine that runs when the chip is started or reset. These setting can viewed by opening the ASM file ( after compiling your code). PMD2 defaults to 0 at POR. and remains at 0 unless intentionally disabled.
My questions are:
1) Why do you think you need to change these registers?
2) What is the actual issue?
Last edit: William Roth 2021-07-11
Did Jeff try the revised program I posted? As the use of constants and bits was all messed up?
See this post. https://sourceforge.net/p/gcbasic/discussion/579125/thread/ac3ccb1c84/#5db0
Jeff's latest code attached here - No explanation by Jeff as to why it was posted.
@Jeff
If you need help please describe the problem. Simply posting code tells us very little.
Also, I asked you two questions in my post above but you seemed to ignore them. If you want good help it is important to provide feedback to those taking the time to help.
William
Last edit: William Roth 2021-07-13
Thank you for your comments Mr Roth. What I found was that the 1st program I posted was hanging , after being verified as correctly programmed, when I ran the chip wired to the LCD Nothing printed.wrt the Print(s) LCD at the end of the program and I have another program which prints when tested which even has #CONFIG DEBUG=ON What I suspected was that ANSELA.2 and ANSELA.3 were at their default value of high disabling the digital input buffer.Ignorance of the procedure you mentioned above wrt to the ASM file. So I have included the 2 statements ANSELA.2=0 ANSELA.3=0 to enable the dig input buffer on RA2 and RA3.
So I sent you the new short program again for which i figured that an expert like you could glance and see if there were any mistakes without a problem.There are a few comments at the top to describe the action.Anything outstanding in respect of a glance and a mistake here in the new short program?
If ANSELA.2 and ANSELA.3 have been cleared as you say they have then I really have a problem.
Thanks very much for your help much appreciated .
@Jeff
You still have not told us what the actual problem is given the the latest code.
Does the program still "hang"?
Does the LCD Display initialize and correctly display characters? Yes or No?
Most LCD displays require 5.0V. A few require 3.3V
What LCD Display are you using . Brand/ Model
Why are you using LCD RW ? Do you need to read the LCD memory ?
Why did you set the LCD Pin Directions with DIR PORTC OUT ( this is done automatically via the LCD library )
Why do you have CLKOUT enabled on RA6 with #Config INTIO7 ?
Why have you set PORTE. 3 as an input ?
It seems to me that you have made a lot of incorrect assumptions that have lead to unnecessary code.
If it were me I would start from scratch and first get the LCD display working
with minimal code. Then, confident that the the LCD is working correctly, add in
sections of code one at a time, verifying as you go.
For Reference: When a GCB program starts. ALL ANSEL registers are Cleared to 0 and ALL Pins are set as digital inputs. This is the real default.
So first tell me does the LCD Display work? Yes or No?
Last edit: William Roth 2021-07-16
Thanks for your time and consideration. Good news is that the new program works.
Many thanks to Mr Venn too. Enjoy the weekend.