Serial monitor on Mplab for pic microcontroller

Thread Starter

guetkar

Joined Mar 9, 2022
45
Hi guys,

I used to use Arduino, and it's very helpful to use the serial monitor for debugging.

Actually I'm using Mplab (for pic microcontroller). Does any one know if there is a similar tool on Mplab to a serial monitor, that can be used for debugging please ?

Thanks
 

AlbertHall

Joined Jun 4, 2014
12,345
There is the simulator. You can single step a program, view and change registers and variables. You can set up an input data stream with whatever your project requires. There is a logic analyser to view output pins. I think it is a lot better than the serial monitor.
 

BobTPH

Joined Jun 5, 2013
8,813
When running under the sinulator you can direct any UART output to a window. After selecting simulator as a ge debug tool, go to simulator options and select UARTx IO Options to turn it on.

Bob
 

Thread Starter

guetkar

Joined Mar 9, 2022
45
Thanks Bob,

I tried to use it, but I was quite lost, does the simulator run after loading the firmware on the chip, or the μC is even not necessary (just a simulation). I looked for a useful tutorial that may explain this clearly ... It wasn't possible to find a good one, do you know any useful one for that ?

Thanks
 

AlbertHall

Joined Jun 4, 2014
12,345
The uC is not needed. In the project configuration select simulator as the tool and click in the left margin of the editor to set breakpoints (shown by a red/pink mark). Click the debug project button. This will run the program in the simulator and it wil stop at the first breakpoint it comes to. Then you can use the step, step over, etc buttons.

Try this: https://www.siriusmicro.com/mplabx-c.html
 

Thread Starter

guetkar

Joined Mar 9, 2022
45
Ok, thanks

What if I want to interface the μC, and get a reading from a device (sensor for example). How can I display the recieved data ?

Thanks
 

AlbertHall

Joined Jun 4, 2014
12,345
While running in the simulator you will not get readings from a real world sensor. Probably not a task for a beginner to the simulator but you can set up timed actions on pins to simulate a sensor then you can check how your program handles this.

Alternatively, you can connect the uC and sensor and run it in debug mode. You have fewer options this way, but you can set breakpoints and view variable, register, and port values.
 

BobTPH

Joined Jun 5, 2013
8,813
Ok, thanks

What if I want to interface the μC, and get a reading from a device (sensor for example). How can I display the recieved data ?

Thanks
The simplest way would be to just temporarily change the code that reads the sensor to teturn a constant.

Bob
 

mysteral

Joined Feb 8, 2018
3
"change the code that reads the sensor to return a constant", I don't see what you mean ?
I had a problem with a PIC where I thought the AD converter was returning an incorrect value. I added a small sub-routine that was called after the AD conversion. It read each bit of the AD conversion registers (10 bit in this case) and then turned on or off a couple of LEDs connected to spare pins on the output port. (The circuit already had an LED display, so this was no problem) It would read each bit, display an LED red if the bit was 1 or green for 0, wait for a short period to give me time to record the state before proceeding to the next bit. I also added a button to push to continue the program to the next break point. The same could be done to read any register on the PIC. Just call the sub-routine wherever necessary.
 

Lourens

Joined Jul 16, 2012
15
I had a problem with a PIC where I thought the AD converter was returning an incorrect value. I added a small sub-routine that was called after the AD conversion. It read each bit of the AD conversion registers (10 bit in this case) and then turned on or off a couple of LEDs connected to spare pins on the output port. (The circuit already had an LED display, so this was no problem) It would read each bit, display an LED red if the bit was 1 or green for 0, wait for a short period to give me time to record the state before proceeding to the next bit. I also added a button to push to continue the program to the next break point. The same could be done to read any register on the PIC. Just call the sub-routine wherever necessary.
Hi, you can write a piece of software for your PIC that receive(from your pc) an address of a register and then transmit the registers value, which is then displayed on your pc screen.
 

click_here

Joined Sep 22, 2020
548
I mean mostly when running the hardware @click_here
I use a program called "putty" - There are other programs out there, but I also use the other functions, like raw sockets. "Brays Terminal" is another I like.

To get it from the microcontroller to the computer, I use a Prolific USB/RS232 converter. Also, because you are looking at RS232, you'll need to convert uart to it using something like the MAX232.
 
Top