Any Assembler (for PIC) wizards out there?

This is the place for any magazine-related discussions that don't fit in any of the column discussion boards below.
dyarker
Posts: 1750
Joined: Fri Aug 22, 2003 1:01 am
Location: Izmir, Turkiye; from Rochester, NY
Contact:

Re: Any Assembler (for PIC) wizards out there?

Post by dyarker » Tue Dec 28, 2004 9:00 pm

With 5V supply, and LED resistors around 75 to 175 Ohms, and square-wave present; sounds like LEDs are reversed in circuit.<p>C U L -
Dale Y

User avatar
philba
Posts: 2050
Joined: Tue Nov 30, 2004 1:01 am
Location: Seattle
Contact:

Re: Any Assembler (for PIC) wizards out there?

Post by philba » Tue Dec 28, 2004 10:10 pm

To verify if IR LEDs are getting lit, get a camcorder and look at the LED through the monitor. The video chip is sensitive to IR and you will see the flashing (try looking at a remote control in use).

User avatar
philba
Posts: 2050
Joined: Tue Nov 30, 2004 1:01 am
Location: Seattle
Contact:

Re: Any Assembler (for PIC) wizards out there?

Post by philba » Tue Dec 28, 2004 10:37 pm

<blockquote><font size="1" face="Verdana, Helvetica, sans-serif">quote:</font><hr>Originally posted by NE5U:
Colin- Yes, OSCAL is defintely zero'd by this line"
<blockquote><font size="1" face="Verdana, Helvetica, sans-serif">code:</font><hr><pre>movwf OSCCAL ; Load factory oscillator calibration value</pre><hr></blockquote>. I had to put the ORG0x00 statement in front of the movwf before it would zero though. From what I understand about the ORG (origin) statement, that doesn't really make sense but it worked.
<hr></blockquote><p>I wonder if the emulator has a bug here - does it start executing at 0 or 3FF? as I understand it, the processor program counter is set to 0x3FF upon reset. That causes it to execute the instruction in the last word of program memory (0x1FF in the F206 case, I believe). This contains a MOVLW <osccal> instruction. The program counter then rolls over to 0 and executes your code there. At that point, the W register should contain the oscillator calibration value and the movwf OSCCAL does the right thing. <p>Also, the picstart should (though I'm not 100% certain it does) preserve the MOVLW <osccal> at the last location of program memory. I know my MELabs EPIC+ programmer does. Try reading the flash memory of the chip and look at the last location. It should be something other than 0x3FF.

User avatar
philba
Posts: 2050
Joined: Tue Nov 30, 2004 1:01 am
Location: Seattle
Contact:

Re: Any Assembler (for PIC) wizards out there?

Post by philba » Tue Dec 28, 2004 10:53 pm

More thoughts - what voltage for Vdd are you using? I've had trouble using a PIC (12F629) to directly drive an LED to full brightness when using 3V. It appeared that the pin was not able to source enough current. I was never able to get a completely straight answer on why. I used a transistor (2N3904, IIRC) to drive the LED no problem.

Mike6158
Posts: 409
Joined: Fri Nov 12, 2004 1:01 am
Location: Weimar, Texas
Contact:

Re: Any Assembler (for PIC) wizards out there?

Post by Mike6158 » Wed Dec 29, 2004 5:44 am

Dale Y- Since this is the internet I could just say that my LED's were installed correctly :) But they weren't :) But that was the first thing that I checked, thumped myself on the head, and then corrected :) Still no light. I tested the red led and it does indeed light when powered.<p>Philba- I didn't EVEN think about using a camcorder to read the LED's. Actually, I gave mine to my son when he transferred to his duty station in Florida but I have a digital camera. I'll give that a try.<p>Vdd is 5V.<p>Concerning where it starts. I originally wrote 0x00 but I can't be sure of that. I wasn't looking for it to start anywhere, just 0 the W register and then OSCAL, which it does or at least appears to do. Since the oscillator seems to work I assume that the OSCAL register is zero'd.<p>Will the 3904 turn off and on fast enough?
"If the nucleus of a sodium atom were the size of a golf ball, the outermost electrons would lie 2 miles away. Atoms, like galaxies, are cathedrals of cavernous space. Matter is energy."

dyarker
Posts: 1750
Joined: Fri Aug 22, 2003 1:01 am
Location: Izmir, Turkiye; from Rochester, NY
Contact:

Re: Any Assembler (for PIC) wizards out there?

Post by dyarker » Wed Dec 29, 2004 5:45 pm

The IR LEDs might have been "blown" if connected in reverse. Yesterday I checked a spec sheet (via digikey), PIV is only 5V!<p>Cheers,
Dale Y

User avatar
philba
Posts: 2050
Joined: Tue Nov 30, 2004 1:01 am
Location: Seattle
Contact:

Re: Any Assembler (for PIC) wizards out there?

Post by philba » Wed Dec 29, 2004 9:20 pm

<blockquote><font size="1" face="Verdana, Helvetica, sans-serif">quote:</font><hr>Originally posted by NE5U:

Concerning where it starts. I originally wrote 0x00 but I can't be sure of that. I wasn't looking for it to start anywhere, just 0 the W register and then OSCAL, which it does or at least appears to do. Since the oscillator seems to work I assume that the OSCAL register is zero'd.<p>Will the 3904 turn off and on fast enough?
<hr></blockquote><p>Actually, you dont want to zero the OSCCAL reg, you want to load it with the "trim" value that microchip wrote into the last location of flash. The value you load into OSCCAL changes the internal RC frequency. See the datasheet for details. You can tweak this value to get your frequency closer to 38Khz (that would be 3.952 Mhz). You want to ORG your program at 0 but the processor will execute the movlw <osccal value> and then start executing your code at 0 (with the trim value in W reg).<p>Yeah, the 2N3904 will switch plenty fast, it has an Hfe of 35 at 10 MHz. but I doubt you need it at 5V, the PIC will drive your LEDs just fine. <p>Also, most LEDs are plenty resiliant to reverse connections at 5V. I bet they are OK. <p>Phil

dyarker
Posts: 1750
Joined: Fri Aug 22, 2003 1:01 am
Location: Izmir, Turkiye; from Rochester, NY
Contact:

Re: Any Assembler (for PIC) wizards out there?

Post by dyarker » Thu Dec 30, 2004 12:01 am

And they don't work while the red one does because? ...
Dale Y

Mike6158
Posts: 409
Joined: Fri Nov 12, 2004 1:01 am
Location: Weimar, Texas
Contact:

Re: Any Assembler (for PIC) wizards out there?

Post by Mike6158 » Thu Dec 30, 2004 5:24 am

Well... I don't KNOW that the IR LED doesn't work yet. The detector would occasionaly output a square wave that had the same frequency as the IR LED was supposed to have but not reliably. That's what made me start to wonder if the IR intensity was high enough. I guess I left that little bit of info out. Sorry about that...
"If the nucleus of a sodium atom were the size of a golf ball, the outermost electrons would lie 2 miles away. Atoms, like galaxies, are cathedrals of cavernous space. Matter is energy."

User avatar
philba
Posts: 2050
Joined: Tue Nov 30, 2004 1:01 am
Location: Seattle
Contact:

Re: Any Assembler (for PIC) wizards out there?

Post by philba » Thu Dec 30, 2004 7:41 pm

<blockquote><font size="1" face="Verdana, Helvetica, sans-serif">quote:</font><hr>Originally posted by Dale Y:
And they don't work while the red one does because? ...<hr></blockquote><p>many possible reasons why they don't work. Or they could be working just fine and the detector not working. Its a good idea to consider all the possibilities when debugging a circuit. <p>I have reversed more LEDs in 5V circuits than I'd like to admit. Some for hours and every single one of them worked when I reinstalled them correctly.<p>Probably the best thing to do is just hook up the LED to +5 with the appropriate dropping resistor and look at them through a cam. That will eliminate the guess work.<p>[ December 30, 2004: Message edited by: philba ]</p>

JKMADSCI
Posts: 17
Joined: Tue Nov 19, 2002 1:01 am
Location: QUEENS
Contact:

Re: Any Assembler (for PIC) wizards out there?

Post by JKMADSCI » Fri Dec 31, 2004 2:36 pm

I just spent 4 hours troubleshooting an intermittent lockup on a pic 16f684 because i forgot about how the current memory bank must be restored in the interupt routine. Does any one know why the pics cant be designed with ONE BANK
of memory and ONE BANK of program space?
Is it a money thing? Id pay double for a pic if they would design it with one bank. Heck if they throw in a compare immediate id pay $15.<p>
friends dont let friends pull into the wrong bank

User avatar
philba
Posts: 2050
Joined: Tue Nov 30, 2004 1:01 am
Location: Seattle
Contact:

Re: Any Assembler (for PIC) wizards out there?

Post by philba » Fri Dec 31, 2004 3:05 pm

<blockquote><font size="1" face="Verdana, Helvetica, sans-serif">quote:</font><hr>Originally posted by JKMADSCI:
I just spent 4 hours troubleshooting an intermittent lockup on a pic 16f684 because i forgot about how the current memory bank must be restored in the interupt routine. Does any one know why the pics cant be designed with ONE BANK
of memory and ONE BANK of program space?
Is it a money thing? Id pay double for a pic if they would design it with one bank. Heck if they throw in a compare immediate id pay $15.<p>
friends dont let friends pull into the wrong bank
<hr></blockquote><p>Been there, done that, cursed pic designers, too. <p>The memory bank thing is the way they handled upward compatibility when making PICs with more memory. Bad choice on Microchip's part, IMO.<p>I particularly love the way you get access to the full program space (PCLATH is a true curse). Oh and let us not forget the skip instructions. You have to do a double flip mentally to get it right (I use the pseudo ops to make it a little better). And why didn't they make W a real reg so you can do orthogonal ops against it - I spend way too much time juggling my code to get the right value in a reg instead of W.<p>By the way, sublw is basically a compare immediate.<p>I suggest you take a look at the AVR from Atmel. Much cleaner design with few of the incredibly annoying quirks of the PIC. <p>OK, now why I like/use PICs. There is no processor with more support out there, more designs and a broader range of versions (for that perfect fit). PICs are most forgiving of incorrect use - I dont know how many times I've wired them backwards and the chip got incredibly hot (ever get an M burned into your thumb?) and it still worked ok when wired up right. And PICs are very forgiving of programming errors. AVRs are very easy to screw up so you have to pull the chip out of the circuit to reprogram it (try that with an SMD).<p>Sigh, warts and all, I still use PICs.

bodgy
Posts: 1044
Joined: Tue Dec 04, 2001 1:01 am
Location: Australia
Contact:

Re: Any Assembler (for PIC) wizards out there?

Post by bodgy » Sat Jan 01, 2005 12:46 pm

The 18F series address some of those shortcomings.<p>WREG is addressable,
Most programmers will not have to worry about banking.
Some proper compare instructions - not as many as a cisc based system.
A Latch register for the ports to obviate the RWM problem.<p>If using MPLAB or a HLL compiler there is very little porting work to be done to move a 16F projetc to an 18F one.<p>In fact if you live in a country where the 18F's are readily available I'd recommend starting with this series for beginners.<p>Colin
On a clear disk you can seek forever.

User avatar
philba
Posts: 2050
Joined: Tue Nov 30, 2004 1:01 am
Location: Seattle
Contact:

Re: Any Assembler (for PIC) wizards out there?

Post by philba » Sat Jan 01, 2005 11:27 pm

bodgy, I agree that the 18 series does address some of the problems but they need to make smaller PICs in this line. I really love the little ones because I can basically replace a lot of logic with the 8 pin 12F629 or 12F509. Banking doesn't come into play but all the ugliness of the instruction set is there. Atmel got it right - same architecture from the top to the bottom.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 32 guests