Show Posts
Pages: [1] 2 3 ... 8
1  Using Arduino / Microcontrollers / Re: Program At89S51 with Arduino SPI library on: September 12, 2014, 03:05:04 pm
That code snippet should program 0x4141 in page 0, commit the page and read one byte back in.
Doesn't it do that?

B.t.w. I think you'll learn things much faster if you study existing code that does this kind of things.

Personally, I found it helphfull to add println's to ArduinoISP and observe it in action. But to do that, you need an arduino (sanguino, leonardo, mega...) with an extra uart for the printl's because avrdude uses the default one.

Alternatively you could study Nick Gammon's programmer.  It has the serial port free for println's and it does exactly what you are building.

 
2  Using Arduino / Microcontrollers / Re: Program At89S51 with Arduino SPI library on: September 03, 2014, 02:57:17 pm
Maybe it blinks but only weakly? I just observed that he ports p1 through p3 cannot source a lot of current.
So if you wire like this:  "mcu port - led anode - R330 - ground", the led only lights up weakly.
If wire like this "mcu port - led cathode - R330 - 5V" it is more bright. Current is then about 15mA which is on the edge of the spec.

Does the hex file in the avr freaks link I sent above work?

I noticed that after programming the flash, I have to power cycle the chip, but you probably already tried that.
(In mean time I manage to program the chip using (a modified) ArduinoISP)


3  Using Arduino / Microcontrollers / Re: Program At89S51 with Arduino SPI library on: September 01, 2014, 02:11:01 am
6MHz should be ok but it is worth tring with another crystal. Mine is 12 MHz. caps are 2x 20 pF.

@erni: What I don't understand either is that usbasp manages to read the signature bits: for the at89s52 thse are not in contiguous places in memory, they are at 0, 0x100 and 0x200. I wonder how usbasp manages to read these 3 bytes, without special ad hoc code,  just with the info coming from avrdude?
4  Using Arduino / Microcontrollers / Re: Program At89S51 with Arduino SPI library on: August 31, 2014, 10:38:42 am
Wiring reliable? caps and crystal close enough to ic?
Maybe post a pic of your setup.
5  Using Arduino / Microcontrollers / Re: Program At89S51 with Arduino SPI library on: August 30, 2014, 01:13:46 pm
A couple of years ago I wanted to explore the 8051. For this purpose I sampled two types of the more recent at89lp series. I added at89lp support into ArduinoISP so I could use avrdude to program the chips.
I digged up that project and am adding support for the at89s52 which looks not a lot of work. I can keep you posted if you want.
6  Using Arduino / Microcontrollers / Re: Program At89S51 with Arduino SPI library on: August 30, 2014, 01:05:06 pm
It is not defined (in the datasheet) what is shifted in while you shift out the first 3 bytes.
But while you shift out the 4th byte, you should see 0x69 being shifted in.
It does not matter what you shift out as 4th byte but is makes sense to shift out 0x00 and check whether you shift in 0x69:
Code:
#define ENABLE_PROGRAMMING 0xAC530000L


I tried your sketch on a leonardo connected to an at89s52. I see this:
Code:
11111111111111111111111101101001
The 4th byte reads 0x69 indeed.

I extended the skech so it also reads in the signature bytes:
Code:

#define READ_SIGNATURE_0  0x28000000L
#define READ_SIGNATURE_1   0x28010000L
#define READ_SIGNATURE_2  0x28020000L
...

sendCmd(READ_SIGNATURE_0, true);
sendCmd(READ_SIGNATURE_1, true);
sendCmd(READ_SIGNATURE_2, true);

This gives me this extra output:
Code:

00000000001010000000000000011110
00000000001010000000000101010010
00000000001010000000001000000110
The last bytes from each line are: 0x1E 0x52 0x06, which is indeed the signature of an at89s52.



7  Using Arduino / Microcontrollers / Re: Program At89S51 with Arduino SPI library on: August 26, 2014, 02:54:41 pm
Interesting link. Though it is not using ArduinoISP, it uses some sketch dedicated to the programming tool also available on that side.

In my reply above, my expectation that avrdude+ArduinoISP could do the job is wrong: ArduinoISP does not interprete info from avrdude about e.g. what command to issue for a "program enable". All this is hard coded... When I come to think about it, this is a pity: ArduinoISP is used by a lot of people and it could be a lot more usefull if it used more of the info coming from avrdude...
8  Using Arduino / Microcontrollers / Re: Program At89S51 with Arduino SPI library on: August 25, 2014, 04:46:15 pm
Quote
I'm asking my self also on how the data is programmed on the chip after sending the "Programming enable instruction" is by using MOSI itself or I have to put something on the address line and data line ?
SPI is a serial interface, everything is sent on MOSI and read from MISO.
Quote
"...Serial programming instruction set"  page 20 the byte 2, 3, 4 have "xxxx A11 A10 A9 A8" or "A7 A6 A5 A4 A3 ..." and I'm struggling to understand what they mean by these.

It means you first send the opcode (byte1), then in byte 2 you send the highest bits of the address (highest 4 bits are don't care: xxxx),  byte 3 holds the 8 least significant bits of the address and finally byte 4 is the data you want to write at that address.

Quote
My request is there someone can answer me about  what I've asked and tell me if this project is feasible or not ?
It is feasable and a good exercise as you indicate.
But assure yourself you want to do the exercise: incidently I just bought a  programmer (an sp200s clone) for only 12$, that can do the at89s52. It seems to work but it is black box, you don't see what is happening so this does not learn you anything on ISP or SPI of coarse.

If you are still convinced you want to do it from your arduino, this link may be interesting:
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=printview&t=99161
It indicates you can program the at89s52 with avrdude + usbasp. I would expect that avrdude + arduinoISP should work too.



9  Development / Other Software Development / Re: Modify USB profile to remove serial port - just want keyboard on: August 25, 2014, 04:06:49 pm
Have a look at the snippets in this message: http://forum.arduino.cc/index.php?topic=137032.msg1033088#msg1033088. It is about leaving out the hid device and keeping only serial. You want to do the opposite, but that is a similar task.

If this is for use with windows, you'll also need to create a .inf file that instructs windows to use the generic hid driver when it sees your usb 'product'. It is best to use a product id different from the leonardo's, such that windows can handle correctly both a standard serial+hid leonardo and your customized one. (note you can use arduino's vendor id only for personal use, experimentation).
On linux this is all transparent, it will pick the right driver based on the usb class info your firmware exposes.


Quote
Normally the bootloader enumerates a keyboard, mouse, and serial port,

Actually the bootloader exposes serial port only, it is the sketch that is started afterwards that exposes serial + hid.
10  Products / Arduino Yún / Re: Connect yun mini usb with yun USB A does not work. on: January 21, 2014, 04:00:09 pm
You can ignore that message.
It only means the USB device is just a simple serial line, not a modem.
If you connect the Yun to a linux pc, the pc will give the same error message, but you can of coarse perfectly communicate with it.
11  Products / Arduino Yún / Re: Use Yun bridge without a Yun? on: October 17, 2013, 03:20:10 pm
Ok, I did a git pull and ran from there.

Note that the overloaded function SerialBridgeClass::begin(int baud) in the new code is wrong, the baud rate must be an unsigned long for baudrates like 115200 to work. Adding just an optional baud argument like in my code snippet works also and is backward compatible too.

I observed not behavioural differences. On the Leonardo it works a bit faster than on the Duemilanove. As said, I will  try to figure out where the latencies come from. Does this run smoothly on the Yun?

12  Products / Arduino Yún / Re: Use Yun bridge without a Yun? on: October 16, 2013, 03:31:06 pm
I would not be surprised if the developers used a regular arduino and a pc to develop the bridge.

I gave it a try with a Duemilanove (I have no Uno) and a Leonardo.

When compiled for the Leonardo, the bridge library uses Serial1 (the uart), so you have to hook up a serial to usb converter to the tx (1) and rx (0) pins. Communication with the bridge goes via this extra converter. But the upside is that you have Serial free for println debugging.

When compiled for the Duemilanove, the bridge library automatically uses Serial, so communication goes via the (only) usb cable.

As suggested elsewhere in this forum I added the possibility to start the bridge with a specified baudrate. In Bridge.h I made this change:
Code:
class SerialBridgeClass : public BridgeClass {
...
  void begin(unsigned long baud = 250000) {
    serial.begin(baud);
    BridgeClass::begin();
  }
I feel more comfortable with 115200 as baudrate, so in the ConsoleRead sketch:
Code:
Bridge.begin(115200);

Upload e.g. the ConsoleRead sketch to the Duemilanove, Leonardo....

The bridge library does not set the baud rate, so you should do that yourself:
Code:
stty -F /dev/ttyUSB0 115200

Get the YunBrigde source from Arduino's git hub repository.

The avr on the Yun fires up the bridge on linino by itself, but for experimentation on the pc you can just start it manually. e.g. for the Duemilanove:
Code:
python bridge.py </dev/ttyUSB0 >/dev/ttyUSB0

The bridge  will try to run the scripst /usr/bin/blink-start and /usr/bin/blink-stop. You might comment this out in packet.py, but I just installed two dummy scripts on my pc and made them executable:
Code:
#!/bin/sh
echo "$0" 1>&2

In the scripts, make sure not to echo stuff (for debugging) on stdout because it will be sent to the arduino, messing up the bridge communictaion. That is what the 1>&2 is for: it makes sure echo's output ends up on stderr. Likewise if you want to do 'printf debugging' from the python scripts, don't use print, but use:
Code:
from sys import stderr
...
stderr.write("some string\n").

The arduino may kick out the  python script by sending it the 'XXXXX' command. Just start it again or ignore the command in bridge.py.

Now, in another terminal window, say telnet localhost 6571 and you should see 'Hi, what's your name?'

I did not yet manage to make it run smoothly though. If I type my name, it takes several seconds till I see 'Hi peter! Nice to meet you!'
It looks as if for every send from the arduino to the pc, there is a latency of a second or so. I want to figure out where this comes from...I have no Yun, so I don't know whether it runs smoother on a Yun. I see no reason why it would. On the Yun, there is no usb to serial converter involved but that should not be a bottle neck?. Maybe I did not yet find the magic stty settings?.
13  Products / Arduino Yún / Re: Statically linking C++ programs in Linino on: October 04, 2013, 04:14:17 pm
Long time ago I had to do the same thing, on a much different platform. There may be more sophisticated solutions, but I simply renamed the libstdc++.so* files, such that the linker does not find them. The linker will fallback to linking statically against the corresponding .a files. Other libs will still be linked dynamically,   

Are you sure this still is relevant? I have no Yun so I don't know whether all packages you install ends up in the flash or on the micro sd card. If you can put it on the micro sd, I would just use libstdc++.so. On the other hand, I built linino and searched for elf images needing libstdc++, there are indeed only a few that do.
14  Products / Arduino Yún / Re: Connecting a arduino to Linino on: September 17, 2013, 03:02:56 pm
Is an udev rule needed for this? (Don't know for the yun). But if one is needed, it must match the vid/pid and module name of the duemilanove's ftdi:
Code:
BUS=="usb", SYSFS{idVendor}=="0403", SYSFS{idProduct}=="6001", RUN+="/sbin/modprobe ftdi_sio"
15  Products / Arduino Due / Re: atmega16u2 bootloader not working on: September 03, 2013, 03:37:56 pm
To verify whether the flash content is identical to the that of a given hex file you can use avrdude:
specify the given hex file, and as memory operation specify v for verify, like this:
Code:
... -U flash:v:path_to_hex_file.hex:i

This avoids the problem that avrdude writes the hex file with a different record length compared to the hex file produced by building the bootloader.

That said, if anyone can suggest a good (linux) utility to convert intel hex to binary, I would be interested. (so you could just compare two differently formatted hex files).
Pages: [1] 2 3 ... 8