Hello All-
New to this compiler. Have used PIC Basic Pro for over 30 years but they have not added much in recent - so I am looking for another compiler. While free, this looks to be quite capable - Kudos to All involved!
In learning this complier, I am trying to simply read a couple of bits and turn on a couple of LEDs - not working at all.
It is so simple that I must be violating some blatant setting - but cannot find it. Read and looked at many examples (much easier that PIC Basic Pro) but my simple program does not work.
Thanks in advance for any support.
The test file is here:
//first,chipconfig#CHIP18F67K40'Who we are//Defines#defineBLEDPORTF.0'BLUE lede, active LOW#defineRLEDPORTF.1'RED led, active LOW//#definebledINPORTE.0'Input for Blue ledbledIN=PORTE.0'An alternative to above to test//#definerledINPORTE.1'Input for Red led//#optionVolatilePORTE.0'This did not help//InitdirPORTEIn'Sets up PORTE for INPUTSdirBLEDout'Sets the DIRdirRLEDoutBLED=1'Turns OFF the ledRLED=1'Same as above//Main//HerewegoBoyz......DoBLED=bledIN'Hopefully led will follow input//RLED=rledIN'same as aboveLoop
Here's what I would try:
//first,chipconfig#CHIP18F67K40'Who we are//Defines#defineBLEDPORTF.0'BLUE lede, active LOW#defineRLEDPORTF.1'RED led, active LOW#definebledINPORTE.0'Input for Blue ledbledIN=PORTE.0'An alternative to above to test#definerledINPORTE.1'Input for Red led//#optionVolatilePORTE.0'This did not helpDimSwitchStateRLedAsBitDimSwitchStateBLedAsBitLetSwitchStateRLed=0LetSwitchStateBLed=0//InitdirPORTEIn'Sets up PORTE for INPUTSdirBLEDout'Sets the DIRdirRLEDoutBLED=1'Turns OFF the ledRLED=1'Same as above//Main//HerewegoBoyz......DoLetSwitchStateRLed=RLedInLetSwitchStateBLed=BLedInLetBLED=SwitchStateBLed'Hopefully led will follow inputLetRLED=SwitchStateRLed'same as aboveLoop
Untested but I wonder if you are not assigning the 'state' of the input to your output, but the value of its port position - which will always be the same regardless of whether the button is pressed or not.
Last edit: Ccin E Crout 2023-07-26
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks Ccin E Crout - your idea was the same.
With no input the LEDs are ON, when bringing the input to a '1' the LED still stays ON.
If we remark the DO loop, the LEDs stay off as supposed to.
It seems that I still cannot read an input - even with your suggestion.
This should be quite simple....... now frustrating.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry that did not help. I had a distant recollection that I'd had a similar problem and found that referencing the inputs indirectly helped me in that case. I may have been trying to do maths with the result of an input which may have been my problem. I easily may have mixed things up totally. Yet again.
I certainly have been able to read inputs simply using GCB, but I'm not familiar with the device you are using.
As it appears that something else is wrong. I'll leave you in the hands of someone with much more knowledge than me.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks Anobium-
I have gone back to my original (code attached) but the LEDs do not change from inputs on the 2 bits on the port.
I feel this is such a simple problem and searching the forum has not had any 'illumination'.
Thanks and feeling somewhat better that it is not me.......
Appreciate your looking at this.
However, it still does not change state of the LEDs based on the input of the port.
Code Attached.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Apologies for my unclear message. I am somewhat better with the knowledge that the issue I am having is not me but something in the compiler.
Your suggestion did not help, but I do however, appreciate your efforts.
I have attached the program one more time - hopefully doing it correctly this time <grin>.
Regards.</grin>
I was not aware you are on vacation - and you are willing to help - that is great!
The target has already been designed and it is using PORTA.
I wondered the same line of reasoning however.
I will find some other pins and try the same test and be sure to let you know.
I programmed the board in PIC Basic Pro by the way but am looking to find an other compiler.
Regards.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
What is puzzling me... the compiler has had this issue since 2013 or before. The BSR register was being set directly, which failed (silently and correctly) and then the subsequent setting of ANSELx was not operating as expected.
I will resolve properly in the next build.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anobium-
Thank you for confirming that it may not be my very simple 'test' prog. the test program is so simple I did not see how it could fail - given my past history with another compiler however.
I am mentoring a bright young person and unfortunately I have given him my board specific programming cable and need to wait for the RJ-12 connectors in order for me to test anything. They should be arriving later today - Texas time.
I can test some of the registers you wanted, but again, this board is already designed and known to work properly albeit with a different compiler. I can change those registers associated with a LCD and 2 8-bit ports later when I re-build a board-specific programming cable.
Again, I am impressed with the compiler thus far, and your interest in solving the compiler issue is heart-felt.
Enjoy your time in France.
Regards.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you.
There seems to be a problem with my programming cable.
Target does not agree with the programmer.
I am out of town starting to9morrow until Thursday (Central Time) morning.
Will be able to get back to it then.
Regards,
Steve
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anobium-
I have fixed the programming cable (simple) and have used your suggestion for ONE port which is input PORTD.
I am having no luck with your suggestion if I understand it correctly.
Program is attached.
Have a glass .......
Regards,
Steve
Hello All-
New to this compiler. Have used PIC Basic Pro for over 30 years but they have not added much in recent - so I am looking for another compiler. While free, this looks to be quite capable - Kudos to All involved!
In learning this complier, I am trying to simply read a couple of bits and turn on a couple of LEDs - not working at all.
It is so simple that I must be violating some blatant setting - but cannot find it. Read and looked at many examples (much easier that PIC Basic Pro) but my simple program does not work.
Thanks in advance for any support.
The test file is here:
Here's what I would try:
Untested but I wonder if you are not assigning the 'state' of the input to your output, but the value of its port position - which will always be the same regardless of whether the button is pressed or not.
Last edit: Ccin E Crout 2023-07-26
Thanks Ccin E Crout - your idea was the same.
With no input the LEDs are ON, when bringing the input to a '1' the LED still stays ON.
If we remark the DO loop, the LEDs stay off as supposed to.
It seems that I still cannot read an input - even with your suggestion.
This should be quite simple....... now frustrating.
Sorry that did not help. I had a distant recollection that I'd had a similar problem and found that referencing the inputs indirectly helped me in that case. I may have been trying to do maths with the result of an input which may have been my problem. I easily may have mixed things up totally. Yet again.
I certainly have been able to read inputs simply using GCB, but I'm not familiar with the device you are using.
As it appears that something else is wrong. I'll leave you in the hands of someone with much more knowledge than me.
adding
#option explicit
would hilight the issue.bledIN is not declared.
If you change to a constant using the
'#define
then the program should work.The ASM looks correct when the constant is used.
Where F.0 is set off, then F.0 is set only if E.0 is High,
Thanks Anobium-
I have gone back to my original (code attached) but the LEDs do not change from inputs on the 2 bits on the port.
I feel this is such a simple problem and searching the forum has not had any 'illumination'.
Please add to the top of your program the following:
The root cause of the issue is that port has not been added to the initsys sub routine. I will add for the next release. But, for now. add that code.
Last edit: Anobium 2023-07-26
Thanks and feeling somewhat better that it is not me.......
Appreciate your looking at this.
However, it still does not change state of the LEDs based on the input of the port.
Code Attached.
Hit the key too soon.
Here is the file.....
Damn, hit the wrong button!
Really, here it is.....
What now works ? what changed? I cannot help with 'that is somewhat better'.
Here to help - best regards.
Apologies for my unclear message. I am somewhat better with the knowledge that the issue I am having is not me but something in the compiler.
Your suggestion did not help, but I do however, appreciate your efforts.
I have attached the program one more time - hopefully doing it correctly this time <grin>.
Regards.</grin>
As I away, on vacation at the moment, I do not have a chip here....
So, we need to elimate a few things.
Change the program to use PORTA. This will prove if the basics are operating as expected.
I was not aware you are on vacation - and you are willing to help - that is great!
The target has already been designed and it is using PORTA.
I wondered the same line of reasoning however.
I will find some other pins and try the same test and be sure to let you know.
I programmed the board in PIC Basic Pro by the way but am looking to find an other compiler.
Regards.
Pleasure.
Add the following where
a..h
is A thru to H. So, add multiple time.Then, change the PORTE for the inputs to LATE
So, there is an issue deep the compiler, easily fixed, hence the conditional statements. I cannot fix here in France.
Test above changes and report back.
What is puzzling me... the compiler has had this issue since 2013 or before. The BSR register was being set directly, which failed (silently and correctly) and then the subsequent setting of ANSELx was not operating as expected.
I will resolve properly in the next build.
Anobium-
Thank you for confirming that it may not be my very simple 'test' prog. the test program is so simple I did not see how it could fail - given my past history with another compiler however.
I am mentoring a bright young person and unfortunately I have given him my board specific programming cable and need to wait for the RJ-12 connectors in order for me to test anything. They should be arriving later today - Texas time.
I can test some of the registers you wanted, but again, this board is already designed and known to work properly albeit with a different compiler. I can change those registers associated with a LCD and 2 8-bit ports later when I re-build a board-specific programming cable.
Again, I am impressed with the compiler thus far, and your interest in solving the compiler issue is heart-felt.
Enjoy your time in France.
Regards.
Thank you.
Test the simple program. I need to know it works. I see the bit changing in MPLAB-X so I am very hopeful.
Thank you.
There seems to be a problem with my programming cable.
Target does not agree with the programmer.
I am out of town starting to9morrow until Thursday (Central Time) morning.
Will be able to get back to it then.
Regards,
Steve
Anobium-
I have fixed the programming cable (simple) and have used your suggestion for ONE port which is input PORTD.
I am having no luck with your suggestion if I understand it correctly.
Program is attached.
Have a glass .......
Regards,
Steve
ok. Wait until your return - ping me when you are back.
Anobium-
I am back and can help further this issue.