0
\$\begingroup\$

I am a fresher to Mplab. I wanted to know how to fire RCREG. I have tried many internet searches and still not successful. Please help me out with this. I just wanted to input, let's say "A" into RCREG. How do I do this using Stimulus in MPLAB?

thanks, Phani Anne

\$\endgroup\$
3
  • \$\begingroup\$ please explain: "fire" = ? \$\endgroup\$ Commented Nov 6, 2011 at 15:30
  • 1
    \$\begingroup\$ Fire can be activated using the MPLAB Stimulus function. \$\endgroup\$ Commented Nov 6, 2011 at 15:57
  • \$\begingroup\$ @Hans - Seems I was 1 second too late to make the same change :-) \$\endgroup\$ Commented Nov 6, 2011 at 16:02

2 Answers 2

1
\$\begingroup\$

See the MPLAB SIM Help (Stimulus Dialog):

Click the button in the Fire column corresponding to the row for which you want to trigger the stimulus. Obviously, you must set up all other row items before you can use "Fire".

You should use the Microchip MPLAB forum for this sort of question.

\$\endgroup\$
4
  • \$\begingroup\$ Hi Leon, Thanks for the reply. Yes, I need to setup some other settings too. But what are the steps? I pressed fire button 10000000000000 times. Still the value in RCREG doesn't change. I couldn't figure out what's else to do \$\endgroup\$ Commented Nov 6, 2011 at 17:10
  • 1
    \$\begingroup\$ How? I tried these commands " movlw 0x41 movwf RCREG"; still the value of RCREG does not change. I am very desperate about this. I have a big project to do on this USART and now I can't inject a value into RCREG to debug my code. RCIF has to be set if something is in RCREG. I can't inject a value and then the loop goes on forever. \$\endgroup\$ Commented Nov 6, 2011 at 22:08
  • \$\begingroup\$ RCREG can only be loaded by the UART hardware. \$\endgroup\$ Commented Nov 6, 2011 at 22:36
  • 1
    \$\begingroup\$ But for debugging, we don't connect the real hardware. Right? There has to some way to inject a value into RCREG virtually. Otherwise, MPLAB would not list RCREG in the drop down list under Asynch tab. \$\endgroup\$ Commented Nov 6, 2011 at 22:57
0
\$\begingroup\$

To place a value into RCREG using stimulus:

Use MPSIM, select stimulus.
Create a new workbook
Select the Asynch tab and create a new line by clicking on the blank area.
Select Pin/SFR->RCREG using the dropdown list.
Select Action->Direct Message using the dropdown list Select comments/message, and write your required value(s) in the hex format e.g. 0x55. Alternatively you can create a text file with the values and select Pin/SFR->File Message then select file in the Message/Comments box.
Press Save, then Apply.
Select RCREG in the watch window.
Compile and run the simulation, when you want to inject the value press fire (the > button)
Stop the simulation and the register should have changed in the watch window.
I just confirmed this works on my laptop, note that it seems you can only change it once though. You can also use the register injection in a similar way but the triggering is not manual (e.g. program counter/event)

I think you can simulate serial data input on the UART directly (i.e. as read from the Rx pin)
Check the MPSIM help and read the stimulus section. It mentions limitations (i.e. how accurately it can simulate certain peripherals if it can at all) so it should give details about the UART.

\$\endgroup\$
3
  • \$\begingroup\$ Thanks for the reply. I am trying the same in my laptop. You are lucky, it worked atleast once for you. For me, no luck. Not even once. I just did it right now. Still no use. Also, When I open a new project, I don't see any MPSAM suite to create a new project. I have to load an old project first, then, I have to create a new project. If i just open MPLAB and try to create a new project, It doesn't work. Did I install MPLAB right? Could this be the reason for RCREG firing not to work? \$\endgroup\$ Commented Nov 6, 2011 at 23:23
  • \$\begingroup\$ You rock man. It's not like, firing RCREG works only once. There is a time interval between firing and loading the RCREG. I did it. We just to run some code between this time. Then RCREG gets loaded, and blah blah. Now, have to figure out this time interval. Maybe , this has to do something about the baud rate. Anyway, thanks for your help. Really appreciate it. \$\endgroup\$ Commented Nov 6, 2011 at 23:43
  • \$\begingroup\$ No problem, glad it worked. I had a feeling it should fire more than once but couldn't figure it out quickly. Have a good read of the help (under help->topics->MPSIM) and check the register injection out too. There are plenty of useful things that can be done with the stimulus once you get the hang of it. Good luck with the rest of your project. \$\endgroup\$ Commented Nov 7, 2011 at 0:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.