Hi,
I can not get anything out of USART with Hsersend on PIC 16F15376 (Mplab Xpress card)
I tested both USART 1, RC6 and USART 2, RB6
Updating GCB with the latest full package download did not help.
Am I doing something wrong or is there a compiler error?
Here a very basic test program. Led blinks on RA0, but the RC6 stays low.
No difference. RC6 still does not ouput anything. There are no bits at all sent. (I am measuring the RC6 pin directly to an oscilloscope and an amp+speaker is also connected which should produce a "tick" every 200ms).
Last edit: Roger Jönsson 2021-02-28
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The 16F15376 is a PPS enabled chip. While the TX1 Output defaults to PortC.6 per the datasheet I have found that the PPS must be set for proper operation on this family of chips.
Try this code with the PPS set up.
;ChipSettings#chip16F15376,16#OPTIONEXPLICIT#STARTUPInitPPS,85#defineUSART_BAUD_RATE115200#defineUSART_TX_BLOCKINGDIRPORTA.0OUT'LED?DIM COUNTER as BYTECOUNTER = 0Do HserPrint COUNTER HserSend 32 // Space HserPrint "Great Cow BASIC" HserPrintCRLF PORTA.0 = NOT PORTA.0 // Toggle LED Wait 500 ms COUNTER++ // increment counter by 1LoopSub InitPPS 'Module:EUSART1RC6PPS=0x000F'TX1>RC6EndSub
Last edit: William Roth 2021-02-28
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have confirmed that the RC6PPS register defaults to a value of 0 (unmapped) on Power On Reset.
Therefore TX1 is not mapped to RC6 unless it is setup via PPS. This seems to be the case with all PIC microcontrollers. The RX1 Defaults to RC7 as expected, however TX1 output does not.
I think it should be standard good practice to always setup the PPS when using the USART on a PPS enabled PIC. GCB has a built in PPS tool to make this very easy.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes, I used the built in PPS tool (good thing to have hady!) while Anobium was editing the last message above and got it to work with the pin that was supposed to be default according to the data sheet.
As RX1 was working, it was extra weird that TX1 wasn't. Pretty bad that the datasheet that I downloaded again today is still wrong (it isn't exactly a new chip).
Anyway. I appreciate the help and is happy that I got it sorted out!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The Pin Allocation Tables for 16F153xx chips are incorrect in the datasheet where they show TX1/TX2 as allocated to RC6/RB6 respectively. No peripheral outputs are initially allocated on PPS chips at POR.
However the Register 15-2 RxyPPS Table on Page 243 of the datasheet shows that ALL RxyPPS registers default to 0 at POR. This means that these are all initially set up as standard I/O pins and not mapped to any specific peripheral output.
Rxy is defined where "x" is the Port and y is the Bit. eg. RC5 or PORTC.5
Last edit: William Roth 2021-02-28
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I can not get anything out of USART with Hsersend on PIC 16F15376 (Mplab Xpress card)
I tested both USART 1, RC6 and USART 2, RB6
Updating GCB with the latest full package download did not help.
Am I doing something wrong or is there a compiler error?
Here a very basic test program. Led blinks on RA0, but the RC6 stays low.
Last edit: Roger Jönsson 2021-02-28
try HSerPrint which will convert the 1 and 0 to ascii and you can see it on the terminal.
No difference. RC6 still does not ouput anything. There are no bits at all sent. (I am measuring the RC6 pin directly to an oscilloscope and an amp+speaker is also connected which should produce a "tick" every 200ms).
Last edit: Roger Jönsson 2021-02-28
I used the 16F15376 yesterday. Serial was working.
Please install the latest release candidate.
I just looked at your code.... this is a pps chip!
See the demos in .. \GreatCowBasic\Demos\vendor_boards\mplab_xpress_board_pic16f15376 folder - you need to look at demo 10_board_status_to_serial.gcb
I just looked at your code.... this is a pps chip!
See the demos in .. \GreatCowBasic\Demos\vendor_boards\mplab_xpress_board_pic16f15376 folder - you need to look at demo 10_board_status_to_serial.gcb
The 16F15376 is a PPS enabled chip. While the TX1 Output defaults to PortC.6 per the datasheet I have found that the PPS must be set for proper operation on this family of chips.
Try this code with the PPS set up.
Last edit: William Roth 2021-02-28
Thanks. That works.
Why do I need to assign TX1 to a new pin? Why is it not by default RC6 as in the PIC16F15376 datasheet?
I have confirmed that the RC6PPS register defaults to a value of 0 (unmapped) on Power On Reset.
Therefore TX1 is not mapped to RC6 unless it is setup via PPS. This seems to be the case with all PIC microcontrollers. The RX1 Defaults to RC7 as expected, however TX1 output does not.
I think it should be standard good practice to always setup the PPS when using the USART on a PPS enabled PIC. GCB has a built in PPS tool to make this very easy.
Because the Datasheet is wrong in this case.
Yes, I used the built in PPS tool (good thing to have hady!) while Anobium was editing the last message above and got it to work with the pin that was supposed to be default according to the data sheet.
As RX1 was working, it was extra weird that TX1 wasn't. Pretty bad that the datasheet that I downloaded again today is still wrong (it isn't exactly a new chip).
Anyway. I appreciate the help and is happy that I got it sorted out!
The Pin Allocation Tables for 16F153xx chips are incorrect in the datasheet where they show TX1/TX2 as allocated to RC6/RB6 respectively. No peripheral outputs are initially allocated on PPS chips at POR.
However the Register 15-2 RxyPPS Table on Page 243 of the datasheet shows that ALL RxyPPS registers default to 0 at POR. This means that these are all initially set up as standard I/O pins and not mapped to any specific peripheral output.
Rxy is defined where "x" is the Port and y is the Bit. eg. RC5 or PORTC.5
Last edit: William Roth 2021-02-28