I'm working with Northern Software's .NET SDK and it has the capability of connecting, resetting and programing PICs all via .NET software. So it's a VERY useful tool. I'm currently working on a VB.NET front end to take advantage of all those things.
One thing that is also possible is the ability to connect via a USART channel. I can create two way communication between the NS chip and the target MCU. (My recent posts are related to this capability)
Communication is a bit quirky when it comes to sending data from NS to a PIC, but I found that if I send only 1 character byte commands from NS to PIC, it seems to work quite well. The goal is to control the PIC via a 1 character command set to do some special stuff (ie, count frequencies to calibrate clocks!)
I found on the Great Cow Basic side of things, that reading data from NS in USART BLOCKING mode is rock solid, but the problem with blocking is just that, it BLOCKS my Forever loop.
So I pieced together my own version of the ring buffer. In my case, I really don't need the extra complication of a buffer at all, I'm just expecting to read a 1 byte command on USART channel 2.
So I setup an interrupt to do so, and it seems to work very well. (It took me a while to figure out that my PIC doesn't accept UsartRX2Ready as an interrupt but UART2ReceiveInterrupt)
I only have a few specific commands I want to request the PIC perform, so I will never run out of 1 character commands. In my example below, I am looking for command character '5' and sending back data to NS.
It works, but if you have better suggestions for my case I would love any feedback!
Jeff
'Mini' ring buffer lol:
#CHIPPIC18F16Q40#CONFIGLVP=ON#optionexplicit#startupInitPPS,85#definePPSToolPart18f16q40SubInitPPS'Module:UART1RC6PPS=0x0010'TX1>RC6U1RXPPS=0x0017'RC7>RX1'Module:UART2RC0PPS=0x0013'TX2>RC0U2RXPPS=0x0002'RA2>RX2'Module:UARTpindirectionsDirPORTC.6Out'MakeTX1pinanoutputDirPORTC.7In'MakeRX1pinaninputDirPORTC.0Out'MakeTX2pinanoutputDirPORTA.2In'MakeRX2pinaninputEndSub'USARTsettingsforUART1andUART2'#defineUSART_BAUD_RATE9600'#defineUSART_BLOCKING#defineUSART2_BAUD_RATE9600#defineUSART2_BLOCKINGDimInCharasBytewait3s'SetupUSART2InterruptInitUSART2'MainroutineDoForever'DostuffLoop'SetupInterruptSubInitUSART2'InterruptHandler-somehaveRCIEandsomehaveU1RXIE,sohandle#IFDEFBIT(RCIE)OnInterruptUsartRX2ReadyCallReadUSART2#ENDIF#IFDEFBIT(U2RXIE)OnInterruptUART2ReceiveInterruptCallReadUSART2#ENDIFEndSubSubReadUSART2'GetCommandcharfromUSART2.ItreadingthedatainblockingmodeknowingtheresdataworksbestformeInChar=HSerReceive2SelectCaseInCharCase53'byte value for '5'ThisuartchannelwillONLYbeexpecting1charactercommandssonoringbufferneededHSerPrint"Calibration seeing how much information we can send",2HSerPrintCRLF,2Case54'byte value for '6'ThisuartchannelwillONLYbeexpecting1charactercommandssonoringbufferneededHSerPrint"It looks like you want me to perform command 6",2HSerPrintCRLF,2Case55'byte value for '7'ThisuartchannelwillONLYbeexpecting1charactercommandssonoringbufferneededHSerPrint"Looks like command 7 has been pressed.",2HSerPrintCRLF,2CaseElse'sendbackchartoUART2,ignoringinreallifeHSerSendInChar,2HSerprintCRLF,2endselectEndSub
Last edit: Jeff Weinmann 2022-08-17
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Evan and William,
I'm working with Northern Software's .NET SDK and it has the capability of connecting, resetting and programing PICs all via .NET software. So it's a VERY useful tool. I'm currently working on a VB.NET front end to take advantage of all those things.
One thing that is also possible is the ability to connect via a USART channel. I can create two way communication between the NS chip and the target MCU. (My recent posts are related to this capability)
Communication is a bit quirky when it comes to sending data from NS to a PIC, but I found that if I send only 1 character byte commands from NS to PIC, it seems to work quite well. The goal is to control the PIC via a 1 character command set to do some special stuff (ie, count frequencies to calibrate clocks!)
I found on the Great Cow Basic side of things, that reading data from NS in USART BLOCKING mode is rock solid, but the problem with blocking is just that, it BLOCKS my Forever loop.
So I pieced together my own version of the ring buffer. In my case, I really don't need the extra complication of a buffer at all, I'm just expecting to read a 1 byte command on USART channel 2.
So I setup an interrupt to do so, and it seems to work very well. (It took me a while to figure out that my PIC doesn't accept UsartRX2Ready as an interrupt but UART2ReceiveInterrupt)
I only have a few specific commands I want to request the PIC perform, so I will never run out of 1 character commands. In my example below, I am looking for command character '5' and sending back data to NS.
It works, but if you have better suggestions for my case I would love any feedback!
Jeff
'Mini' ring buffer lol:
Last edit: Jeff Weinmann 2022-08-17