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.

Feedback on Schematic

Status
Not open for further replies.
It's so heart warming to know that I'm not alone in the world. :D

I think tonight (if I don't fall asleep at 7:00) I will be looking at properly setting up the clock/oscillator configuration.
 
Will do. After I get home etc etc. It was just supposed to turn on the LED's, and I've probably missed something glaringly obvious. It was after all the first attempt. I was very pleased that the programmer recognized the 2550 and allowed me to program it (but not to put it in debug mode).
 
Let me guess, late/early morning things all go wrong...sleep works..lol

-BaC

LabRat said:
Will do. After I get home etc etc. It was just supposed to turn on the LED's, and I've probably missed something glaringly obvious. It was after all the first attempt. I was very pleased that the programmer recognized the 2550 and allowed me to program it (but not to put it in debug mode).
 
Heh heh.. yep. Some VERY late nights on this one. Didn't realize how much this was affecting me until I was trying to debug something at work.

I attempted to copy a line of code
Code:
HDelay(45000);// Some useless inline comment

became
Code:
HDelay(8000);
HDelay(45000); // Some useless inline comment

and then I went to comment out the original.

Code:
HDelay(8000);
;HDelay(45000);// Some useless inline comment

Oddly enough it took me 10 minutes to track down why the delay was still so large.:eek: Too much playing with PIC Assembler at 2:00 am the night before.
 
What made it "hard to read"
For old timers like myself, wires that hook things together are preferable to chasing around the page for matching names.

But there are just as many who prefer a schematic like the one you presented.
 
blueroomelectronics said:
Can you post the code?
Whoo hoo!!

I tracked it down. While I was waiting for the laptop to boot in order to post the code, I realized that my MCLR was not isolated enough. I removed my 20k pullup and switch from the board, and voila - the device can run and be debugged!!

I like it when things start to come together. At this rate I will be doing my board layout by the end of the weekend. :rolleyes:

I've been playing with Eagle so far, but the board I want to create should be about an inch wider than the "Free Eagle" default size(s). Any recommendations for other packages? Or do I attempt to divide this up into three smaller boards (CPU, Left I/O, Right I/O)
 
HMmmm... now it has once more stopped working, and I didn't change the HW at all. Must be because it is passed 11:00 at night. I guess I will have to try again tomorrow.
 
Are you powering your target from USB? (Junebug suppling power?) If so keep the LCD backlight off as they generally draw more than 100mA
 
These LCD don't actually have backlights. At the moment I was just trying to run a simple led blink, powered off of the JuneBug connection. It was working earlier for a brief while. I'm upgrading my IDE to 8.02 in case that has/had anything to do with it.

Attempts to program the target are getting back an Error 0028: Unable to enter debug mode.
 
Hmm, 8.02 works fine for me. Is the oscillator running on the target chip. What is your CONFIG line? Make sure you DON'T turn off the fail safe clock till you're sure your program is running.
 
My code is very simple and based on some earlier published LED blinking.

Code:
/*
 * Includes the generic processor header file. The correct processor is
 * selected via the -p command-line option.
 */
#include <p18cxxx.h>
#include <timers.h>

#define NUMBER_OF_LEDS 2

void timer_isr (void);

static unsigned char s_count = 0;

/*
 * For PIC18xxxx devices, the low interrupt vector is found at 000000018h.
 * Change the default code section to the absolute code section named
 * low_vector located at address 0x18.
 */
#pragma code low_vector=0x18
void low_interrupt (void)
{
  /*
   * Inline assembly that will jump to the ISR.
   */
  _asm GOTO timer_isr _endasm
}

/*
 * Returns the compiler to the default code section.
 */
#pragma code

/*
 * Specifies the function timer_isr as a low-priority interrupt service
 * routine. This is required in order for the compiler to generate a
 * RETFIE instruction instead of a RETURN instruction for the timer_isr
 * function.
 */
#pragma interruptlow timer_isr

/*
 * Define the timer_isr function. Notice that it does not take any
 * parameters, and does not return anything (as required by ISRs). 
 */
void
timer_isr (void)
{
  static unsigned char led_display = 0;

  /*
   * Clears the TMR0 interrupt flag to stop the program from processing the
   * same interrupt multiple times.
   */
  INTCONbits.TMR0IF = 0;

  s_count = s_count % (NUMBER_OF_LEDS + 1);

  led_display = (0x20 << s_count++);

  /*
   * Sets the special function register PORTB to the value of led_display.
   */
  PORTC = led_display;
}

void
main (void)
{
  /*
   * Initialize the special function registers TRISB and PORTB.
   */
  TRISC = 0;
  PORTC = 0;

  /*
   * Enable the TMR0 interrupt, setting up the timer as an internal
   * 16-bit clock.
   */

  OpenTimer0 (TIMER_INT_ON & T0_SOURCE_INT & T0_16BIT);
  
  /*
   * Enable global interrupts.
   */
  INTCONbits.GIE = 1;
  while (1)
    {
    }

}

Using the Configuration Bits - I have Divide by 5 pre-scaler (20MHz input), and Oscillator bits set to 5 - EC +CLK0 {RA6} (not 100% sure this is correct, but was working earlier)
 
Haha yep that and lack of sleep will get you every time:) A good clear the head does wonders when working in asm too much..lol

-BaC
LabRat said:
I'm looking at this thread where you had answered an almost identical question:
https://www.electro-tech-online.com/threads/junebug-pk2error0028.37774/

I will chase this for a bit, but as of 2 minutes ago the 1320 wasn't being recognized. Almost like I fried something somehow. Perhaps a good dose of leaving it alone for a night will fix things. :)
 
Just for fun (assuming you're using a 20MHz crystal & a 18F2550)
Code:
#include <p18F2550.h>
#include <timers.h>
#pragma CONFIG FOSC = HSPLL_HS, WDT = OFF, LVP = OFF
#pragma CONFIG PLLDIV = 5, CPUDIV = OSC1_PLL2
#define NUMBER_OF_LEDS 2
 
Thanks guys. I tried Bills program he posted in the other thread, to check on the crystals, and low-and-behold everything started working again. I suspect that I somehow messed up my oscillator settings, and I don't know enough yet, as to what to check etc. Having reprogrammed with "good settings" everything seems to be working again.

Three steps forward... two steps back.. three steps forward...


(time for bed)

Thanks again everyone. Have a good "what's left of your evening" ;)
 
Haha, good idea, ditto.

-BaC

LabRat said:
Thanks guys. I tried Bills program he posted in the other thread, to check on the crystals, and low-and-behold everything started working again. I suspect that I somehow messed up my oscillator settings, and I don't know enough yet, as to what to check etc. Having reprogrammed with "good settings" everything seems to be working again.

Three steps forward... two steps back.. three steps forward...


(time for bed)

Thanks again everyone. Have a good "what's left of your evening" ;)
 
Another day.. another set of problems.:p

LED's are blinking, and timings appear to be set up. I can still get the device into an odd state, and PicKit2 responds with low voltage error (2.4v). To recover I need to cycle the power and restart MPLAB. (At least there is a work around).

Attempting to get the LCD running now. Problem of course is that I was using RB6 which is hooked up to the debug lines. So I've reworked the demo code with delays for a 20MHz clock (used an online web tool to generate the delay code), and moved the A0/RS line to be on RB4. I can see that everything is clocking (Logic probe), but the LCD isn't happy just yet. I will have to run these with a scope handing in order to measure the width of the pulses (just to make sure).

For now :YAWN:.. time to pack it in (Yep.. 10:15.. an early night):D
 
  • Like
Reactions: 3v0
Status
Not open for further replies.

Latest threads

Back
Top