I'm just starting up with GCB, trying to debug a program that's not working as expected. I'm using Win 8.1 with MPLAB X and a PICkit3. When running a program, is there a way to send the value of a variable back through the PICKit3 to the Terminal Window?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you are using MPLABX you can see variables in the variables window.
Window>Debugging>Variables
That's assuming your PIC supports debugging.
If it's 20 pins or less and does not have an F1xxx part number then it probabaly doesn't support debugging.
I prefer to do all development on a 28 pin PIC16F886 so I have all the I/O I need and can debug in MPLAB. Then once its working I can easily adjust the code to fit the part I want.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you don't see the UART Tool under the PICKit 3 Tools menu selection, then you need the PICKit 3 app with scripting support. Install that, and use GCB hardware RS232 (if the chip supports it) commands to send variable thru to the Uart Tool window. The scripting software emulates the PICKit 2 software, doesn't work with MPLAB in that mode, but I think can be toggled back and forth in MPLAB if need be.
Hard to tell if you are using the GCB Syn Write IDE or not? but highly recommend if not.
If your chip doesn't support hardware RS232, search for recent post on software RS232, and how that has been improved.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well my BAD, looks like the UART tool is greyed out in my PICKit 3! In the 2 years since the scripting software release (June 2013), the promised UART tool has not been updated? This is why the PICKit 2 is so great. In practice, I always use a USB to ttl cable instead.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Agree. I mentioned before on this forum and you've added to it. When using a GCB@SYN I highly recommend the PICkit 2. And since its open source, it can be updated to the latest devices. I cover more about it at my PICkit 2 page. http://www.elproducts.com/build-your-own-pickit-2.html
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I should have mentioned that my development setup is using a 16F1829 on the Low Pin Count Demo Board. The GCB manual shows several examples of commands for sending serial info to an LCD, but I don't see any examples using the terminal program that comes with the GCB Syn download. Thanks for the link to the PICkit2 page, I obtained one of those. Now just have to figure out how to use it.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Can you tell us about your environment? Are you using Great Cow Graphical Basic? or, the GCB@SYN or an alternative editor/development tool? What other kit do you have like a RS232/serial TTL converter?
What chip are you using? and, you found/used the demonstration code? Please attach your code, as an attachment, if you wish - I am sure we can edit for you. :-)
I have the same setup as you. I am certain we can help you.
Anobium
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have taken and edited the code below from one of the demos.
~~~~
' THIS CONFIG OF THE SERIAL PORT DIRECT TO A PC TERMINAL
' USART settings
#define USART_BAUD_RATE 9600
Dir PORTc.6 Out
Dir PORTc.7 In
#define USART_DELAY 5 ms
#define USART_BLOCKING
wait 500 ms
SCKP = 1
; ----- Main body of program commences here.
' Now assumes Serial Terminal is operational
HSerPrintCRLF
HSerPrint "Serial for Microchip"
HSerPrintCRLF 2
~~~
You have to add SCKP - Synchronous Clock Polarity Select bit acts differently depending on EUSART mode.
Asynchronous mode:
•1 - Transmit inverted data to the RC6/TX/CK pin; and
•0 - Transmit non-inverted data to the same pin.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for the suggestions! In response, I have changed to the PICkit2 and chip 18F14K22. Here is a program I'm trying to debug on the Low Pin Count Demo board. It's supposed to flash an LED once if I push a button once. Pushing the button again should make it flash twice and then stop. Third time makes it flash three times and stop. Etc Etc. It works fine the first two times. The third time it just does two flashes again. But the Fourth time it flashes three times, and thereafter only increments for every other button push. I must be overlooking something.
~~~~
#chip 18F14K22, 4
#define BUTTON PORTA.2
#define LIGHT PORTC.1
Dir BUTTON In
Dir LIGHT Out
HOURCOUNT = 0 'initialize HOURCOUNT
NUMCOUNT = 0 'initialize NUMCOUNT
START:
IF BUTTON = 0 THEN 'WAIT FOR BUTTON TO BE PUSHED
WAIT 20 ms
IF BUTTON = 0 THEN 'IS BUTTON STILL PUSHED?
HOURCOUNT = HOURCOUNT + 1 'THEN INCREMENT HOURCOUNT
END IF
ELSE
goto START 'OTHERWISE LOOP UNTIL BUTTON PUSHED
END IF
FOR NUMCOUNT = 0 TO HOURCOUNT 'FLASH LED # OF TIMES THAT BUTTON WAS PUSHED
LIGHT = 1
WAIT 500 ms
LIGHT = 0
WAIT 500 ms
NUMCOUNT = NUMCOUNT + 1 'INCREMENT NUMCOUNT
NEXT
GOTO START
I'm just starting up with GCB, trying to debug a program that's not working as expected. I'm using Win 8.1 with MPLAB X and a PICkit3. When running a program, is there a way to send the value of a variable back through the PICKit3 to the Terminal Window?
If you are using MPLABX you can see variables in the variables window.
Window>Debugging>Variables
That's assuming your PIC supports debugging.
If it's 20 pins or less and does not have an F1xxx part number then it probabaly doesn't support debugging.
I prefer to do all development on a 28 pin PIC16F886 so I have all the I/O I need and can debug in MPLAB. Then once its working I can easily adjust the code to fit the part I want.
If you don't see the UART Tool under the PICKit 3 Tools menu selection, then you need the PICKit 3 app with scripting support. Install that, and use GCB hardware RS232 (if the chip supports it) commands to send variable thru to the Uart Tool window. The scripting software emulates the PICKit 2 software, doesn't work with MPLAB in that mode, but I think can be toggled back and forth in MPLAB if need be.
Hard to tell if you are using the GCB Syn Write IDE or not? but highly recommend if not.
If your chip doesn't support hardware RS232, search for recent post on software RS232, and how that has been improved.
Well my BAD, looks like the UART tool is greyed out in my PICKit 3! In the 2 years since the scripting software release (June 2013), the promised UART tool has not been updated? This is why the PICKit 2 is so great. In practice, I always use a USB to ttl cable instead.
Agree. I mentioned before on this forum and you've added to it. When using a GCB@SYN I highly recommend the PICkit 2. And since its open source, it can be updated to the latest devices. I cover more about it at my PICkit 2 page.
http://www.elproducts.com/build-your-own-pickit-2.html
I should have mentioned that my development setup is using a 16F1829 on the Low Pin Count Demo Board. The GCB manual shows several examples of commands for sending serial info to an LCD, but I don't see any examples using the terminal program that comes with the GCB Syn download. Thanks for the link to the PICkit2 page, I obtained one of those. Now just have to figure out how to use it.
Welcome.
Can you tell us about your environment? Are you using Great Cow Graphical Basic? or, the GCB@SYN or an alternative editor/development tool? What other kit do you have like a RS232/serial TTL converter?
What chip are you using? and, you found/used the demonstration code? Please attach your code, as an attachment, if you wish - I am sure we can edit for you. :-)
I have the same setup as you. I am certain we can help you.
Anobium
See https://sourceforge.net/projects/gcbasic/files/Demonstration%20Files/ for the latest demo files. We will be updating the release later this week.
I have taken and edited the code below from one of the demos.
~~~~
' THIS CONFIG OF THE SERIAL PORT DIRECT TO A PC TERMINAL
' USART settings
#define USART_BAUD_RATE 9600
Dir PORTc.6 Out
Dir PORTc.7 In
#define USART_DELAY 5 ms
#define USART_BLOCKING
wait 500 ms
SCKP = 1
; ----- Main body of program commences here.
' Now assumes Serial Terminal is operational
HSerPrintCRLF
HSerPrint "Serial for Microchip"
HSerPrintCRLF 2
~~~
You have to add SCKP - Synchronous Clock Polarity Select bit acts differently depending on EUSART mode.
Asynchronous mode:
•1 - Transmit inverted data to the RC6/TX/CK pin; and
•0 - Transmit non-inverted data to the same pin.
Thanks for the suggestions! In response, I have changed to the PICkit2 and chip 18F14K22. Here is a program I'm trying to debug on the Low Pin Count Demo board. It's supposed to flash an LED once if I push a button once. Pushing the button again should make it flash twice and then stop. Third time makes it flash three times and stop. Etc Etc. It works fine the first two times. The third time it just does two flashes again. But the Fourth time it flashes three times, and thereafter only increments for every other button push. I must be overlooking something.
~~~~
#chip 18F14K22, 4
#define BUTTON PORTA.2
#define LIGHT PORTC.1
Dir BUTTON In
Dir LIGHT Out
HOURCOUNT = 0 'initialize HOURCOUNT
NUMCOUNT = 0 'initialize NUMCOUNT
START:
FOR NUMCOUNT = 0 TO HOURCOUNT 'FLASH LED # OF TIMES THAT BUTTON WAS PUSHED
LIGHT = 1
WAIT 500 ms
LIGHT = 0
WAIT 500 ms
NUMCOUNT = NUMCOUNT + 1 'INCREMENT NUMCOUNT
NEXT
GOTO START
END
Last edit: Anobium 2015-03-31
NUMCOUNT = NUMCOUNT + 1 is not required.
You are incrementing NUMCOUNT in the for-next.
Remove and test.
Thanks Anobium, you're right. I also had to start the FOR… NEXT loop at 1 instead of zero. Now it does what I want.
Pleasure. Have a hunt through the next demos. Lots of them can be ported to the low count board.