Recently, I was constantly struggling with the fact that microchip was removing more and more support libraries, so it was not wise to rely on them in all projects. Anytime I return again to my old functions – if it used the support libs, there is a pretty good chance it is screwed.
So this code works with XC8 version 2.36 and doesn’t require the involvement of extra support lib.
I was working on a small project where I needed to catch a certain button pressed event. Sounds simple initially, but I have 10 such buttons and it means that I need to have 10 IOs, or port expander, or make a digital matrix button handler (like 3×4 keypad) but these all variants are boring, I wanted something more interesting and make something like a DAC based on these buttons which will be digitazed by the built-in ADC in pic18f14k50. Thus, we will use a single port instead of 10, by cost of the more complicated code.
Let me start as usual – from reading of the datasheet.
This was a time to switch to XC8 compiler, it was not hard at all, but appeared that using of UART in PIC18 series has some peculiarities.
At the moment of this article the XC8 compiler had libraries for work with a periphery in the folder /includes/plib. Now they got rid of it and experimenting with a different approach. Anyway the legacy support looks like quite a strong side for microchip. Well I used then usart.h library which now I regret I did.