Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

mplabx wont debug

Status
Not open for further replies.
Clones are very different inside!!
upload_2016-8-30_9-1-39.png
 
Hi Doc .. the fact your Pickit will 'perform' with a dev board, still suggest your 'lashup' is wobbly, I learned some time ago the BB thing is just asking to waste hours + hair ! its ok for the odd wire ended stuff and occasional IC . My PICbed (TM) :) was quickly knocked up and cheap:happy: . Think you need something similar...
PICbed.jpg

Remembered where I got ZIF from **broken link removed**
 
Last edited:
I'm away from my desk at the moment but, from memory, DEBUG=ON tells it your using the special chip with extra debug connection and not B6,B7.

Mike.
Edit, checked the datasheet.
bit 7 DEBUG: Background Debugger Enable bit
1 = Background debugger disabled, RB6 and RB7 configured as general purpose I/O pins
0 = Background debugger enabled, RB6 and RB7 are dedicated to In-Circuit Debug

However, I'm assuming that ON=1.
 
Last edited:
I notice you have usb port on there, is that how you program? without pickit?

this is what i use for fast programming off the board:

20160909_173818.jpg

but usually its just the demo board used when testing new peripherals, or jumpers to a test BB circuit, i like to start with BB too since most of my designed circuits need tweaking


the 4620 project has its own icsp on the perf board much like grandads example, not as clean though! I just temporarily switched to BB for quick test to ensure that it wasnt perf board or the chip itself or connections failing, which i should mention that despite the looks the icsp wires are short in length and clean connections:

20160909_175129.jpg 20160909_175153.jpg 20160909_175208.jpg
 
I notice you have usb port on there, is that how you program? without pickit?

No, the USB connector is for the PIC which is put into the socket, so the PIC could tack to the PC through USB. USB is easier to wire on PCB than on breadboard. The connector for the programmer is a little bit higher. You can stick PICkit3 into it vertically. Even though it looks flimsy in this position, it works fine. I since then made my own programmes, so I rarely use PICkit3. Here's how the programmers look like:

p5f.jpg


The ICSP connector is the same as on PICkit3. But, since I have built the sockets before I designed the programmers, there is a problem with inserting the programmer into the socket - the USB connector is exactly where UART pins are. So, I had to cut the UART pins from the programmer to use it with the socket. When I make the next socket, I certainly will make it slightly different, perhaps add a connector for the UART pins too. Another idea - since the whole programmer is basically a single small chip - I can put the chip directly onto the socket. This way, I'll have another USB connector instead of 6-pin ICSP and my socket will become self-programmable.
 
and debug with that too?
looks fairly straight forward, looks like it is just passing data, converting protocol from usb to an spi or i2c? just guessing as to icsp protocol is...
 
and debug with that too?
looks fairly straight forward, looks like it is just passing data, converting protocol from usb to an spi or i2c? just guessing as to icsp protocol is...

Yes, can debug too. However, the user interface for the debugger is not written yet.

It's PIC16F1454. It converts USB to SPI which is used in ICSP. There's some added complexity because there are 1200 different PIC models all with different flavours of SPI and their own idiosyncrasies, but otherwise it's all SPI.
 
doesn't the linker or software on the pc side handle that though?

The linker creates a HEX file (or equivalent). It then needs to be translated into a set of SPI commands which PIC can understand and then these commands need to be transferred to the PIC. Part of the translation is done by the programming software running on the PC. Another part is done by the programmer.
 
hmmm ..... i see why they have full confidence in you over there at microchip, and just for record i didn't vote their post down cause of that, i am guessing that its not coincidence that north guy works at northern software ... or id ask for secret code to try updating my clone! ... but it may no longer be required... since my cube matrix works as a good output device for reading registers i was able to use that for debugging to solve the problem, which ended up being a timing delay error for rs232 port.
so now my cube is running nicely again...

have a few 4620 chips left, so I guess it will be simplest to steer away from using them in future designs,

but thanks again this has been informative!
 
ack! more problems again!
same and only pickit,, now using a pic16F688, a soldered up circuit, with only hardware a single common anode rgb led

at first I thought maybe a current overdraw causing brownout(since i tend to forget resistors), but not the case as i have successfully gotten white to light up and not repeat the condition,ie all 3 colors on...

so when i run this code, it turns blue(for boot) but then flashes red to yellow:(, it should stay solid yellow:(

also if i change this line: LED(4);
to this: LED(leds);

then I can see the sequence interval occurring but in a very unusual pattern that i can't seem to decrypt error:
Blue(startup)...
red..green..blue..RED(should be yellow)..BLUE(should be cyan)..RED(should be magenta)...off...repeat

but then on the next cycle the pattern of missing colors is different............ in fact it changes each time






Code:
#pragma config FOSC = INTOSCIO
#pragma config WDTE = OFF
#pragma config PWRTE = OFF
#pragma config BOREN = OFF
#pragma config CPD = OFF
#pragma config CP = OFF
#pragma config MCLRE = OFF
#pragma config IESO = OFF  // Internal External Switchover bit (Internal External Switchover mode is enabled)
#pragma config FCMEN = ON  // Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is enabled)



#include <xc.h>
//#include <htc.h>
//#include <stdio.h>
//#include <stdlib.h>
//#include <pic16f688.h>
#define  _XTAL_FREQ 8000000


void READCAP()
{

  PORTCbits.RC4 = !PORTCbits.RC4;  // outter wire
  PORTCbits.RC5 = !PORTCbits.RC5;  //inner wire

}

void LED(unsigned char col)
{
if ((col == 2)||(col == 4)||(col == 5)||(col == 7)){PORTCbits.RC1 = 0;} else{PORTCbits.RC1 = 1;}  //green
if ((col == 3)||(col == 5)||(col == 6)||(col == 7)){PORTCbits.RC0 = 0;} else{PORTCbits.RC0 = 1;}  //blue
if ((col == 1)||(col == 4)||(col == 6)||(col == 7)){PORTCbits.RC2 = 0;} else{PORTCbits.RC2 = 1;}  //red

}

void setup(void)
{

  OSCCON = 0x70; // switch to 8MHz system clock

  ANSEL = 0b00000000; //All I/O pins are configured as digital
  CMCON0 = 0x07 ; // Disbale comparators
  TRISC = 0b00000000; // PORTC All Outputs
  TRISA = 0b11111111; // PORTA All off for now

  PORTA=255;
  PORTC=255;


}

int main(int argc, char** argv)
{
  unsigned char leds = 0;
  setup();
  PORTCbits.RC0 = 0;  //blue on
  __delay_ms(1000);
  PORTCbits.RC0 = 1;  //blue off
  __delay_ms(1000);

  while(1)
  {
  if (leds>8){leds = 0;}else{leds++;}
  LED(4);
//  READCAP();
  __delay_ms(1000);
  }

}
 
Last edited:
also going back to the original code where LED(4); is used we may notice that my if..if..if is a little out of order:

as i was saying earlier using example1 causes led to flash red..yellow..red.red.red...yellow...repeat
but using example2 causes led to flash like this: green..black..green..black...repeat


EXAMPLE 1)
void LED(unsigned char col)
{
if ((col == 2)||(col == 4)||(col == 5)||(col == 7)){PORTCbits.RC1 = 0;} else{PORTCbits.RC1 = 1;}//green
if ((col == 3)||(col == 5)||(col == 6)||(col == 7)){PORTCbits.RC0 = 0;} else{PORTCbits.RC0 = 1;} //blue
if ((col == 1)||(col == 4)||(col == 6)||(col == 7)){PORTCbits.RC2 = 0;} else{PORTCbits.RC2 = 1;} //red
}

EXAMPLE 2)
void LED(unsigned char col)
{
if ((col == 1)||(col == 4)||(col == 6)||(col == 7)){PORTCbits.RC2 = 0;} else{PORTCbits.RC2 = 1;} //red
if ((col == 2)||(col == 4)||(col == 5)||(col == 7)){PORTCbits.RC1 = 0;} else{PORTCbits.RC1 = 1;} //green
if ((col == 3)||(col == 5)||(col == 6)||(col == 7)){PORTCbits.RC0 = 0;} else{PORTCbits.RC0 = 1;} //blue
}

....all i can think of is fried chip, but have swapped out chip... clone, maybe ... still suspicious of this update, new firmware, and my utterly bad understanding of linkers and such, so no idea how to troubleshoot any of it at all...except trial and error
 
Last edited:
then again,,.. maybe we should look at the code/circuitry, i just switched to 16f526, GCGB compiler, and pickit2 up loader (another clone),

still similar problems,
new code: blue..green..red.. cycle(r..g..b..y..c..m..w..black)
blue & green work, red comes out black on startup, and now both green and red are missing in cycle loops


i wonder, could it be that all this new firmware is clone proof and that these are clone issues still?
 
Last edited:
Could be an RMW issue. Your setting for one bit doesn't have enough time to settle before you start setting the next bit. If you have loads or high capacitance.

Instead of writing directly to PORTC try setting the bits inside a temporary variable, then assign the whole variable to PORTC in a single operation. Such as

C:
unsigned char cols[8] = {7,3,5,6,1,4,2,0};

void LED(unsigned char col) {
  PORTC = cols[col];
}
 
guys! I hope I have mentioned that it is thanks to you all that I still have a full head of hair! I have to admit that over these past few weeks I have that feeling of being a total newb again... so again many thanks! I'd be lost without yall here at ETO!

so this worked great for my led switching issue:
Code:
void LED(unsigned char col)
{
  unsigned char byteout = 7;
  unsigned char porbuf = PORTC & 0b11111000;
  if ((col == 1)||(col == 4)||(col == 6)||(col == 7)){byteout -= 4;}//{PORTCbits.RC2 = 0;} else{PORTCbits.RC2 = 1;}  //red
  if ((col == 2)||(col == 4)||(col == 5)||(col == 7)){byteout -= 2;}//{PORTCbits.RC1 = 0;} else{PORTCbits.RC1 = 1;}  //green
  if ((col == 3)||(col == 5)||(col == 6)||(col == 7)){byteout -= 1;}//{PORTCbits.RC0 = 0;} else{PORTCbits.RC0 = 1;}  //blue
  PORTC = porbuf + byteout;
  __delay_us(100);
}

however I have tried doing the same for a capacitance sensor using the following code, however when i use/hit LINE1 the bits on my LEDs seem to all clear to logic 1, ie all LEDs off....... when i remove LINE1 and replace with LINE2 all values return yellow, so c0=1,c1=0,c2=0, but that is despite the value of level(which gets passed to some if statements which determine the output color)



Code:
int READCAP(void)
{
  unsigned int level = 0;
  unsigned char porbuf = PORTC || 0b00010000;
  PORTCbits.RC5 = 0;  __delay_ms(1000); 
  TRISCbits.TRISC4 = 0; __delay_ms(1000); 
  PORTCbits.RC4 = 1;                      // LINE #1
//  PORTC = porbuf;                        // LINE #2
  __delay_ms(1000);
  TRISCbits.TRISC4 = 1;
  while(PORTCbits.RC4 == 1 & level<5000){level++;__delay_us(10);}  
  TRISCbits.TRISC4 = 0;
  PORTCbits.RC4 = 0;
  
//  PORTCbits.RC4 = !PORTCbits.RC4;  // outter wire
//  PORTCbits.RC5 = !PORTCbits.RC5;  // inner wire
  return level;
}
 
hmm, Have another one for yall!
trying to get porta change interrupt working, specifically on RA0 & 1 , so far I am able to trigger the interrupt routine when i do this: RAIF=1; but not when i trigger a actual change on the port
so far I have done this:


OSCCON = 0b01110001; // switch to 8MHz system clock
ANSEL = 0b00000000; //All I/O pins are configured as digital
CMCON0 = 0x07 ; // Disbale comparators
PORTA = 0;
TRISA = 0b00111011; // PORTA Outputs
OPTION_REG = 0b11000111;
IOCA = 0b00000011;

RAIF=0; // clear flag
RAIE=1; // enable interrupt
GIE = 1; // enable global interrupts

and i call interrupt routine in xc8 for 16f688 chip like this:
void interrupt interupt(void)
{
setRELAY(1);
LED(1);
__delay_ms(300);
setRELAY(0);
LED(0);
Interrupt_occured = 1;
RAIF= 0; // clear flag
GIE = 1; // enable global interrupts
}
 
Status
Not open for further replies.

Latest threads

Back
Top