another strange thing: when I click the Run button, it shows me the following message:
Running... Target halted
Any ideas what could be the problem?
Without reviewing your code it is difficult to offer meaningful advice.
Please post your code using either CODE or SYNTAX tags, so that we can examine it.
One possible issue is the lack of a Super Loop structure, i.e., an infinite loop which prevents code execution from exiting your application.
Unlike application written for platforms with an underlying OS, many embedded platforms lack any OS to which code execution can resume once it exits your application.
Which is why you typically see the following code structure or similar technique employing in embedded applications:
Code:
while(1)
{
//possible sleep or dummy statement
}
Code execution is held within the Super Loop until an interrupt occurs which triggers the execution of an ISR, after code execution exits the ISR it returns to the Super Loop until the next interrupt occurs.
The Super Loop can often contain a statement which when executed force the microcontroller into a low power or sleep mode, i.e., to same power.
ok, another question. I have just started debugging but the part I want to see most is in the ISR which triggers the ADC using PWM special event trigger. But while running in debug mode (Step Into or Animate), it keeps looping around the while loop and never enters ISR.
Is this some sort of limitation with the debug mode? Or is it still possible using some special settings? I know this might be written somewhere in the manuals but I have no idea where to start. I can't seem to find some explanation on google also. Please point me to the right direction.
All methods of debugging have their strengths and weaknesses, rather than single stepping through the code or initiating Animate mode, try setting a breakpoint on a code statement at the end of the ISR and initiate code execution to Run.
After the code executes any initialization routines, it should remain in the Super Loop until an interrupt occurs, which in turn should trigger the execution of the ISR if proper configured and stop at the breakpoint set in the ISR.
One issue to keep in mind when single stepping or setting breakpoints, essentially such debugging techniques take control of the microcontrollers clocking, this can have undesired circumstances in some situations.
An example of just such a situation is debugging UART interaction with serial traffic, while the debugging software and the ICD3 can control the clocking of the microcontroller, in effect slow, pause or stop the code execution, they have no effect on the device receiving or transmitting the data from the microcontrollers UART, which in turn can cause loss of synchronization or data.
Typically these types of situations are best handled with more advanced debugging hardware with Trace features, like the Microchip RealICE.
Or using the ICD3 to set a breakpoint after the UART traffic has been received and examining any buffers which contain the received data.
The manual says Program mode is used only for dspic30f devices. I've never used them so I just keep it on USB/Debug mode
My primary concern was the possibility of the PIC18F interfering with either programming or debugging lines.
It appears the only purpose of the PIC18F is to form a USB to UART bridge to facilitate asynchronous communications with a PC.
Of course, just as the pin location of the PGCx/EMUCx and PGDx/EMUDx pairs from one PIC model to another, so does the location of the TX/RX pairs.
Depending on the specific PIC, you may find this USB to UART bridge nonfunctional in some cases.
BigDog