![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Andreas
Joined: 25 Oct 2004 Posts: 136
|
PIC1813K22 Breakpoint troubles |
Posted: Mon Apr 04, 2016 3:42 pm |
|
|
Hello Friends
I have some unexpected trouble with debugging my code.
I have an ext2 interrupt handler and wanted to stop there, but for some reason MPLABX always tells me that this breakpoint was not recognized.
here my code:
Code: |
#include "c:\Program Files (x86)\PICC\Devices\18F13K22.h"
#include "C:\Program Files (x86)\PICC\Drivers\stdio.h"
// !!!! Nur für neuen Subprocessor !!!!!
#FUSES INTRC_IO,PLLEN,NOPUT,NOBROWNOUT,MCLR,NOLVP,DEBUG,NOWDT
#use delay(clock = 64000000)
#use rs232(baud=38400,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=Com1,errors)
int1 BitLevel = 0;
int1 DecodeData = 0;
int1 StartLow = 0;
int1 SetStart = 0;
int1 LastLevel = 1;
int1 Level;
int8 StartCounter = 0;
int8 DataBits[50];
int8 BitsCounter = 0;
int8 HighBits = 0;
int8 Ccnt = 5;
int8 T2Val = 0x53; // 53 Timer Value for 5 Samples
int8 FreqCycles = 45;
int8 HighCnt = 0;
int8 LowCnt = 0;
int16 InputPeriod;
int16 OldCounterVal = 0;
int16 T2;
#define TXD1 PIN_C6 // TXD COM1
#define RXD1 PIN_C7 // RXD COM1
#define LinearMarker PIN_A1 // Linear Null Marker
#define LogMarker PIN_A2 // Log Null Marker
#define AnalogMP PIN_A0 // Signal Detection Level for AGC !
// Output Signals
#define Yellow PIN_B2 // LED 15 Yellow
#define Code_OK PIN_C2 // LED 16 Green
#define CodeOK1 PIN_C0 // CodeOKLevel1
#define CodeOK2 PIN_C1 // CodeOKLevel2
#define Weg_Imp PIN_B3 // WegImpulsOut
#define Red PIN_B3 // 1200bd Data Out
#define DataDetect PIN_B0 // Data Detection Input after SchmittTrigger
#define SignalQ1 PIN_B4 // Signal Quality 1
#define SignalQ2 PIN_B5 // Signal Quality 2
#define LED PIN_C4 // LED
#define WIDTH (8* sizeof(crc))
#define TOPBIT (1 << (WIDTH -1))
#define POLYNOMINAL 0xA9
// Definitionen für Digitales Poti
#define MAX517_SDA PIN_C5
#define MAX517_CLK PIN_C3
#define MAX517_CS PIN_A5
#define SPI_MODE_0_0 0x4000
#define SPI_MODE_0_1 0x0000
#define SPI_MODE_1_0 0x0010
#define SPI_MODE_1_1 0x4010
#use spi(DO=MAX517_SDA,CLK=MAX517_CLK,ENABLE=MAX517_CS)
// Don't Use Timer1 !!! It's used by the CCP Unit !!!!!!!!!!!!!!
#int_timer1
void timer1_isr()
{
// output_toggle(PIN_B7);
}
#int_timer2
void timer2_isr() // 1200 Bd 166µS 5 Bit Samples
{
}
#int_ext2
void ext2_isr() // 1200 Bd 166µS 5 Bit Samples
{
// output_toggle(PIN_B6);
T2 = get_timer3();
set_timer3(0);
if ( T2 > 400 + FreqCycles ) // > 445 >> Low Frequency ! == 1 Data 443 bei Test
{
output_high(PIN_B6);
}
else
{
output_low(PIN_B6);
}
}
#int_CCP1 // Triggerung auf positive Flanke zur Frequenzmessung
void ccp1_isr()
{
// output_toggle(PIN_B7);
InputPeriod = CCP_1 - OldCounterVal;
OldCounterVal = CCP_1;
if ( InputPeriod > 400 + FreqCycles ) // > 445 >> Low Frequency ! == 1 Data 443 bei Test
{
Level = 1;
HighCnt++;
output_high(PIN_B7);
}
else
{
Level = 0;
LowCnt++;
output_low(PIN_B7);
}
}
void main()
{
setup_oscillator(OSC_64MHZ);
//setup_timer_2(T2_DIV_BY_16,T2Val,2);
setup_timer_1(T1_INTERNAL | T1_DIV_BY_1);
//enable_interrupts(int_TIMER2);
enable_interrupts(int_TIMER1);
enable_interrupts(int_EXT2);
setup_CCP1(CCP_CAPTURE_FE);
enable_interrupts(INT_CCP1);
enable_interrupts(global);
output_float(PIN_C5);
SetStart = 0;
while(True)
{
} // True
} //main
|
I try to set a breakpoint at this line: T2 = get_timer3();
I can see the red square, but it changes as soon as I start the program !
The part of the program with the capture int is working fine !
Hope somebody can show me my mistake in thinking.
best regards
Andreas |
|
![](templates/subSilver/images/spacer.gif) |
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Mon Apr 04, 2016 4:46 pm |
|
|
in a quick look i found this:
Quote: |
set a breakpoint at this line: T2 = get_timer3();
|
YOU NEVER SETUP TIMER 3 in your code....
also
your timer1 - active INT is a time waster - why is it active but with an empty handler ? thats kinda nasty......
Code: |
enable_interrupts(int_EXT2); |
the external INTS in this part have directional options and
i urge you to look closely at the device header file to see if there is a better
EXT2 setup option than the one you chose.
your "break point failure" looks like the LEAST of the trouble with this code.
your CAPTURE code looks bogus too based on the timer one situation--
lastly i notice you are running the part at 64mhz PLL - "top go" to - i assume achieve your "pwm" rate?
IMHO - thats pushing it HARD and i sure hope your circuit design AND LAYOUT is up to the task. |
|
![](templates/subSilver/images/spacer.gif) |
Andreas
Joined: 25 Oct 2004 Posts: 136
|
|
Posted: Mon Apr 04, 2016 11:59 pm |
|
|
Hello asmboy !
Thanks for Your comments, but I explained maybe not detailed enough.
The Interrupt happens, that means the Setup should be okay, my question was related to the Debugging.
I am using a PicKit3 and wanted to set a breakpoint in the ext2 Interrupt handler, the IDE sets this Bp but when I start the program this BP changes to an "unrecognized breakpoint", no I like to know where my fault is.
BTW, You are right with most of Your comments, but this is just a very reduced code snippet only to Show where I see the Problem, all others are working since months already.
best regards
Andreas |
|
![](templates/subSilver/images/spacer.gif) |
Andreas
Joined: 25 Oct 2004 Posts: 136
|
New Version of my testprogram |
Posted: Tue Apr 05, 2016 12:50 am |
|
|
Hello Friends
I have now reduced my program to the min required to show my questions !
Code: |
#include "c:\Program Files (x86)\PICC\Devices\18F13K22.h"
#include "C:\Program Files (x86)\PICC\Drivers\stdio.h"
#FUSES INTRC_IO,PLLEN,NOPUT,NOBROWNOUT,MCLR,NOLVP,DEBUG,NOWDT
#use delay(clock = 64000000)
int8 FreqCycles = 45;
int8 bufcnt = 0;
int16 InputPeriod;
int16 OldCounterVal = 0;
int16 T3;
int16 T3Val[100];
#int_ext2
void ext2_isr()
{
T3 = get_timer3();
if (bufcnt < 100) T3Val[bufcnt++] = T3;
set_timer3(0);
if ( T3 > 400 + FreqCycles ) // > 445 >> Low Frequency ! == 1 Data 443 bei Test
{
output_high(PIN_B6); // At B6 the decoded data is incorrect shown !
}
else
{
output_low(PIN_B6);
}
}
#int_CCP1 // Triggers on postive edge for freqency measuring
void ccp1_isr() // F(low) = 35400 Hz, F(high) = 36600 Hz
{
InputPeriod = CCP_1 - OldCounterVal;
OldCounterVal = CCP_1;
if ( InputPeriod > 400 + FreqCycles ) // > 445 >> Low Frequency !
{
output_high(PIN_B7); // At B7 the decoded data is correct shown !
}
else
{
output_low(PIN_B7);
}
}
void main()
{
setup_oscillator(OSC_64MHZ);
setup_timer_1(T1_INTERNAL | T1_DIV_BY_1);
setup_timer_3(T3_INTERNAL | T3_DIV_BY_1);
enable_interrupts(int_TIMER1);
enable_interrupts(int_EXT2);
setup_CCP1(CCP_CAPTURE_FE);
enable_interrupts(INT_CCP1);
enable_interrupts(global);
while(True)
{
} // True
} //main
|
The decoding of the FSk modulated data is done correct with CCP1 unit !
Now I wanted to change from the CCP1 to the ext2 interrupt, as I have to change to another processor type.
Now my questions:
1. Why is the timer value not counting the same in CCP1 and in ext2 ?
2. Again my question why can't I set a breakpoint in the int handlers ?
Hope somebody can give me the hint !
best regards
Andreas |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Apr 05, 2016 1:35 am |
|
|
Quote: | 2. Again my question why cant I set a breakpoint in the int handlers ? |
The breakpoints problem is a Microchip MPLAB X problem and you should
search their forums and ask about it there. You can use the following
search strings with Google to read their forum archives:
Quote: | site:microchip.com/forums MPLAB X breakpoint interrupt |
and
Quote: | site:microchip.com/forums broken breakpoint |
|
|
![](templates/subSilver/images/spacer.gif) |
Andreas
Joined: 25 Oct 2004 Posts: 136
|
|
Posted: Sat Apr 09, 2016 2:33 am |
|
|
Hello PCM programmer
Thanks for pointing me to Microchip.
As a matter of fact, I couldn't solve it but after a few hours programming
it appears that breakpoints are working again !
It's a miracle................
best regards
Andreas |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|