PDA

View Full Version : ICSP using a 16F84a to program 24CXX



aftab
- 2nd April 2007, 23:51
Hello,

I want to program an I2C (24CXX) using 16F84a.

I want to write "Hello World!" to 24CXX.

Using a JDM programmer(from Olimex) I could program the 24c in ICSP using my computer's serial port.

Using the example that is there in the manual , I could program the 24C using all 8 pins with instructions going out to 24C from 16F84a. But how do I do a ICSP(In Circuit Serial Programming) of 24C ?

If this is the wrong place to ask the question -- where should I ask it ?

Sincerely
Aftab.

skimask
- 2nd April 2007, 23:53
Hello,

I want to program an I2C (24CXX) using 16F84a.

I want to write "Hello World!" to 24CXX.

Using a JDM programmer(from Olimex) I could program the 24c in ICSP using my computer's serial port.

Using the example that is there in the manual , I could program the 24C using all 8 pins with instructions going out to 24C from 16F84a. But how do I do a ICSP(In Circuit Serial Programming) of 24C ?

If this is the wrong place to ask the question -- where should I ask it ?

Sincerely
Aftab.

If the programmer can do 24Cxxx types directly, then install a breakout header like you would for the PIC's ICSP, plug in and program like it was in the socket on the programmer.

aftab
- 3rd April 2007, 00:02
If the programmer can do 24Cxxx types directly, then install a breakout header like you would for the PIC's ICSP, plug in and program like it was in the socket on the programmer.

I did that, but it does not work.

Do I need to do special coding (peek,poke,srout,...) to do an ICSP ?

Somewhere in JDM programmer, it says the voltage goes upto 13v.

I am no electronic geek - so do not understand much.

Any clue what might be the problem ?

Thanks
Aftab

skimask
- 3rd April 2007, 00:22
I did that, but it does not work.
Do I need to do special coding (peek,poke,srout,...) to do an ICSP ?
Somewhere in JDM programmer, it says the voltage goes upto 13v.
I am no electronic geek - so do not understand much.
Any clue what might be the problem ?
Thanks
Aftab

You probably have to add another header or something to cutoff the outside signals going to the 24xxxx itself. You're probably trying to feed power/signals to the whole board, not just the 24xxx, PIC fires up, signals start interfering with each other, etc. Try pulling other chips out, etc.
The JDM programmer voltage is only for the PIC (or maybe other MCU's). 13v would most likely kill a 24xxx.

aftab
- 3rd April 2007, 00:42
You probably have to add another header or something to cutoff the outside signals going to the 24xxxx itself. You're probably trying to feed power/signals to the whole board, not just the 24xxx, PIC fires up, signals start interfering with each other, etc. Try pulling other chips out, etc.
The JDM programmer voltage is only for the PIC (or maybe other MCU's). 13v would most likely kill a 24xxx.

PP 11 of this:
http://ww1.microchip.com/downloads/en/DeviceDoc/31028a.pdf

Shows some driver board - would that be helpful ?

Thanks
Aftab

skimask
- 3rd April 2007, 01:29
PP 11 of this:
http://ww1.microchip.com/downloads/en/DeviceDoc/31028a.pdf

Shows some driver board - would that be helpful ?

Thanks
Aftab

Have you got the datasheet for the 24xxx handy?

aftab
- 3rd April 2007, 12:04
Have you got the datasheet for the 24xxx handy?

Hello,

I have the data sheet for 24cxx.

I think i2c uses very few commands to communicate. Like start,stop, ack, etc.

I came across an article by Jonathan Zacharko in the board of Reynolds Electronics. It shows how to communicate with DS1624 using I2c(dont have the URL, I had googled it and printed in ms word without url). It is interesting.

Just to start - I need to send a few bytes or just "A" to it and write it using the i2c protocol.

Trying for that and will try to post my progress - meanwhile any suggestion would help me.

Thanks - and thanks for so quick responses.
Aftab.

The URL is:
http://www.rentron.com/PicBasic/i2c_communication.htm

skimask
- 3rd April 2007, 14:55
Now I guess I don't know what you really want...you start off talking about 24xxx eeproms and now throw a DS1624 into the mix.
What do you really want here?

aftab
- 3rd April 2007, 19:30
Now I guess I don't know what you really want...you start off talking about 24xxx eeproms and now throw a DS1624 into the mix.
What do you really want here?

I only want to program 24Cxx. The DS1624 is just an example.

I was able to program the 24C04 ic as shown in manual. But I cannot do it in ICSP mode. The example with DS1624 shows how to read/write(?) in ICSP mode(?).

So, for now need to figure out how to program the 24Cxx using i2c commands - as i2cwrite does not seem to work in ICSP mode.

Thanks
Aftab.

skimask
- 3rd April 2007, 20:01
I only want to program 24Cxx. The DS1624 is just an example.

I was able to program the 24C04 ic as shown in manual. But I cannot do it in ICSP mode. The example with DS1624 shows how to read/write(?) in ICSP mode(?).

So, for now need to figure out how to program the 24Cxx using i2c commands - as i2cwrite does not seem to work in ICSP mode.

Thanks
Aftab.

Are you using MeLabs PicBasic or PicBasicPro?
Program the 24C04 as shown in which manual?

aftab
- 3rd April 2007, 20:09
Are you using MeLabs PicBasic or PicBasicPro?
Program the 24C04 as shown in which manual?

This is microEngineering Labs Picbasic Pro v 2.46

The sample code is on pp 53~56 of the spiral bound booklet that comes with it.

An older PDF version of this is downloadable.

thanks
Aftab.

skimask
- 3rd April 2007, 21:41
This is microEngineering Labs Picbasic Pro v 2.46

The sample code is on pp 53~56 of the spiral bound booklet that comes with it.

An older PDF version of this is downloadable.

thanks
Aftab.

Ok, so you want to use the ICSP header, running into the PIC as it would be when you are re-programming the PIC using the JDM programmer...to pass the signals thru to "write to the 24xxx" (as opposed to calling it programming the 24xxx).

As far as pp 53-56 in the manual goes, all I see is info on DATA, DEBUGIN and DEBUGOUT.

mister_e
- 4th April 2007, 00:42
http://www.ic-prog.com/index1.htm

http://www.ic-prog.com/index1.htm

If you're looking for a simple solution, you could skip the PIC and USE ic-PROG (or PONY-PROG) with a SI- Interface

http://www.lancos.com/siprogsch.html

aftab
- 4th April 2007, 02:12
http://www.ic-prog.com/index1.htm

http://www.ic-prog.com/index1.htm

If you're looking for a simple solution, you could skip the PIC and USE ic-PROG (or PONY-PROG) with a SI- Interface

http://www.lancos.com/siprogsch.html

Hi Steve,

Thanks for the links.

What I am trying to do is - I guess you can say that a stand alone i2c programmer for 24Cxx using ICSP.

The following link has the schematic on pp 35:
http://www.imagesco.com/microcontroller/pbc_man.pdf
(the same is on pp 54 of my book)
Also on:
http://www.melabs.com/resources/pbpmanual/

I have successfully wrote/write/programmed 24CXX using that. BUT I want to make one that can do the same in ICSP (In-Circuit Serial Programming).

And I guess that is more complicated. I can do the ICSP using ponyprog/icprog using the ICSP header of olimex board. Interestingly it needs only 3(three wires) - ground,data and clock -- that goes to pin 4, 5 and 6 respectively-- But cannot do the same with my 16f84a programmer. There are few caps, resistors and transistors on the board on which the 24CX is mounted and with drawing power from these three pins, power are supplied to rest of the pins of 24CXX. I want to do the same that olimex icsp is doing. Do the same using my 16f84a.

---------|....................................|--------|
My ........|---------------gnd--------|.24cxx..|
16f84a ...|---------------dat--------|..........|
---------|---------------clk--------|--------|
[DOTS are actually blanks i.e. nothing]

I presume I need to do something like start,stop,ack,... that is used in i2c programming. Some lead would help me.

My knowledge of the exciting world of pic is till now limited to blinking leds and prog one 24cxx on board using the schematic that comes e pbp.

Thanks
Aftab.

skimask
- 4th April 2007, 03:26
I guess I'm still missing something here...

1) Do you want to build a stand-alone (no PC required at all) 24xxx programmer that would have a program already loaded into it, ready to program more 24xxx chips? Basically nothing more than a 24xxx chip copier...

2) Do you want to build you own programmer, capable of only doing 24xxx type chips with a PC connected?

3) Am I still missing a piece of the picture?

aftab
- 4th April 2007, 03:53
I guess I'm still missing something here...

1) Do you want to build a stand-alone (no PC required at all) 24xxx programmer that would have a program already loaded into it, ready to program more 24xxx chips? Basically nothing more than a 24xxx chip copier...

2) Do you want to build you own programmer, capable of only doing 24xxx type chips with a PC connected?

3) Am I still missing a piece of the picture?

Hi - no you are not missing anything. Only thing is my poor way of asking question.

1) Yes - no PC required at all. I program the 16f84a once through PC and then it keeps programming 24xxx(s). And basically it is nothing more than a 24xxx chip copier/firmware updater.

2) That would be nice - but PonyProg can do that using olimex JDM programmer board. But need a PC with com port for that. Parallel ports are gone and com/serial port almost gone. USB is still expensive.

3) So I guess I have been able to give the picture.

This is like:
http://www.winpicprog.co.uk/pic_tutorial_i2c_board.htm

But using only 3 wires instead of 4.
Dat/CLk provides the +ve which is kept in capacitor, transistor and powers the 24cxx. Gnd is Gnd.
Three wire works for JDM program board of olimex - not my poor 16f84.

Thanks
Aftab.

skimask
- 4th April 2007, 04:11
Hi - no you are not missing anything. Only thing is my poor way of asking question.


Ok...I think I might be getting the picture.
Do you have a method to program a 24xxx chip right now?

aftab
- 4th April 2007, 04:24
Ok...I think I might be getting the picture.
Do you have a method to program a 24xxx chip right now?

Yes.
Now I program the 24 using Olimex JDM programmer:
http://www.olimex.com/dev/index.html

Using the ICSP header I connect them as:
http://www.olimex.com/dev/images/pic-icsp.gif
3-Gnd-->gnd of 24CX
4-PGD-->Data of 24CX
5-PGC-->Clk of 24CX

Using windows Pic progarmming software, I can program the 24X

But not by 16f84a.
Could this be a voltage issue ? or Should I try something else than i2cwrite ?

Thanks
Aftab.

mister_e
- 4th April 2007, 04:28
SDA and SCL pin must be pull-up with resistors... as in the manual.

The code example in the manual should work AS-IS

skimask
- 4th April 2007, 04:30
SDA and SCL pin must be pull-up with resistors... as in the manual.

The code example in the manual should work AS-IS

I was just going to say that...along with adding an active pulldown on WP. Datasheet says there's an internal weak pull down, but ya never know.
(BTW - Now I get what you're getting at).

aftab
- 4th April 2007, 04:35
SDA and SCL pin must be pull-up with resistors... as in the manual.

The code example in the manual should work AS-IS

I think I tried that last night - but could have done wrong.
But when I had placed a 24C on my breadboard - it worked.
But when I got 3 connectors to the circuit board with 24C on it, it did not work. However, I shall try that tonight once my classes are over.

But I may sound stupid - till now I do not understand what pull-up means. I shall attach the 4.7k resistors (or other value ?). Only know that resistors are needed to pull-up(?) to program i2c.

Shall post my result of this.

Thanks
Aftab.

skimask
- 4th April 2007, 04:48
I think I tried that last night - but could have done wrong.
But when I had placed a 24C on my breadboard - it worked.
But when I got 3 connectors to the circuit board with 24C on it, it did not work. However, I shall try that tonight once my classes are over.

But I may sound stupid - till now I do not understand what pull-up means. I shall attach the 4.7k resistors (or other value ?). Only know that resistors are needed to pull-up(?) to program i2c.

Shall post my result of this.

Thanks
Aftab.

Pull up....
On signal lines that can be connected to more than one device (in this case I2C's SCK and SDA), the signals aren't powered directly by any of the chips, but by power and the pullup resistors. The various devices can only apply a ground to the signal line. If no devices on the bus are applying a ground, the line stays high (logic 1, at near power supply voltage). If there are multiple devices on the bus, and any one of them applies a ground, the entire signal line drops to ground (logic 0).

If you had each chip holding the signal lines high, and one of them tried to make the signal line a low (logic 0), the other chips would either overpower it, or you'd end up with a lot of smoke in the room :)

Same thing goes for a pull down, but the other way in reverse.

Most of the time, the terms 'pullup' and 'pulldown' aren't so complicated. A pullup just means a high-ish value (4.7K, 10K, etc) resistor between Pin X (or whatever) and the positive supply rail. Conversely for the pull down, a resistor between Pin X and the ground rail.

aftab
- 4th April 2007, 04:58
Pull up....
On signal lines that can be connected to more than one device (in this case I2C's SCK and SDA), the signals aren't powered directly by any of the chips, but by power and the pullup resistors. The various devices can only apply a ground to the signal line. If no devices on the bus are applying a ground, the line stays high (logic 1, at near power supply voltage). If there are multiple devices on the bus, and any one of them applies a ground, the entire signal line drops to ground (logic 0).

If you had each chip holding the signal lines high, and one of them tried to make the signal line a low (logic 0), the other chips would either overpower it, or you'd end up with a lot of smoke in the room :)

Same thing goes for a pull down, but the other way in reverse.

Most of the time, the terms 'pullup' and 'pulldown' aren't so complicated. A pullup just means a high-ish value (4.7K, 10K, etc) resistor between Pin X (or whatever) and the positive supply rail. Conversely for the pull down, a resistor between Pin X and the ground rail.


That was great !

skimask
- 4th April 2007, 05:04
That was great !

Jeeze...finally. I've been a bit off on explanations/corrections/help/etc for a few weeks now. It's about time I got something right. (my 'lab' is under reconstruction due to exterior water intrusion, read that as flooded out...I haven't programmed a PIC in over 2 months!!!). I think I'm suffering from withdrawl...

Anyways...get those resistors fitted and let us know what happens...

aftab
- 5th April 2007, 09:15
Jeeze...finally. I've been a bit off on explanations/corrections/help/etc for a few weeks now. It's about time I got something right. (my 'lab' is under reconstruction due to exterior water intrusion, read that as flooded out...I haven't programmed a PIC in over 2 months!!!). I think I'm suffering from withdrawl...

Anyways...get those resistors fitted and let us know what happens...

Hi,

It worked with the resistors connected. I tried different combination of resistors 1.5,2.2 .. 15k. You guys are correct.

However, the separate circuit board -- the one that I connect with 3 wires when I program it using Olimex JDM board & ponyprog on PC- does not work with the stand alone 16f84. Ponyprog uses i2c commands like start,..write...stop. The source code for ponyprog 1 is available, but not for version 2. And interestingly ICprog does not work with 24CX but it can program the 16f84a.
---|............................|------
PC.|--------JDM------->|24CXX
.....|--------board----->|on a circuit
---|--------ICSP------->|board

I shall try to get an idea by connecting a dataq data logger and see what happens to voltages across the three wires.

If you have a look at the olimex JDM board, there is a led onboard that lits up while reading/writing. While writing to 24CX with ponyprog the led is brighter than when I tried to prgram with ICprog. It means ponyprog can drive the voltage higher - perhaps by repeated/delayed pulse sending to the JDM board; and ICprog cannot do that(chaning the delay in ICprog did not help).

I shall post my results of datag logging - provided I can do that.

Is there a way to attach picture with messages ?

cheers.
Aftab.

mister_e
- 5th April 2007, 15:41
Yes just click on 'manage attachment' and upload your files.

Squibcakes
- 8th April 2007, 12:39
Hi guys,

You can use ICPROG to do this very easy.. see this post from last year...

http://www.picbasic.co.uk/forum/showthread.php?t=4669&highlight=EEPROM

Cheers
Squib