So: Anti software bloat

I just wrote a program for a Microchip PIC 18F14K22 microcontroller driving a ENC28J60 Ethernet controller in ASM. Because this PIC's SPI interface does not work in I bitbanged it,,, As this PIC has only 256 bytes of RAM.....

So far so good... But what does it do??? Well many things, but one of it is that it (oh it has a MAX232 too, ye know a MAXIM chip, I have some, the rumour that those do not exist is false, but you do not need the MAXIM chip you can do it with a NPN transistor and diode), so: It streams the serial port to UDP worldwide, sort of internet radio. At 115200 Bd it just about can send a 64 kbps mp3 worldwide, and you can just hang a player on it (xine, mplayer, ffplay, whatever, best something with a cache or buffer).

115200 Bd is 11520 bytes / second (1 start, 8 data, 1 stop bit), or 92,160 bits / second Add overhead for IP and UDP header... there you are: 64 kbps. Small packets, using a dual buffer in the 256 bytes RAM, while writing via serial interrupt, sending the other buffer via bitbang SPI to the ethernet controller.

So how big is it? Well with my own designed UDP stack: just about 10000 bytes. Yes 10 KILOBYTES.

What more can it do? Oh I added about 2 kilobytes so it can also be used in 'listen' mode, and you can remotely set 2 digital outputs, read 2 digital inputs, read 4 analog

10 bit channels, and set 1 PWM output. For that you need no serial interface at all.. Of all that code size more then 10 % is test routines. Text takes a lot of space. So what OS? No OS. Total parts cost of the unit about 10 $ in small quantities.

Who needs a 'computah' for remote telemetry :-) What 'bloat'?

Now there is free code space, free code space free code space, whatshallwedo with the free code space? I have some idea.

Reply to
Jan Panteltje
Loading thread data ...

with the free code

What about a GUI?

:-)

Nial

Reply to
Nial Stewart

know a MAXIM chip, I have some,

M chip you

Digikey has some LT1081s. They have the same pine out as the MAX232 but is less likely to blow up.

[....]

edo with the free code space?

You could store the manual internally.

Reply to
MooseFET

with the free code space?

version 2 will take care of that

Reply to
AZ Nomad

On a sunny day (Wed, 19 May 2010 05:39:56 -0700 (PDT)) it happened MooseFET wrote in :

I do not remember ever having killed a MAX232 :-)

Yes, I have that in some other PIC project, huge menu. But it would not fit here, with examples I think. It could point to an URL though. mmm idea:-)

Reply to
Jan Panteltje

On a sunny day (Wed, 19 May 2010 10:31:49 -0500) it happened AZ Nomad wrote in :

with the free code space?

version 2 is in the making and will be a very different beast.

Reply to
Jan Panteltje

On a sunny day (Wed, 19 May 2010 12:37:47 +0100) it happened "Nial Stewart" wrote in :

with the free code

You got me there!

>
Reply to
Jan Panteltje

With MS, it is the patches.

Reply to
tm

Jan Panteltje a écrit :

Neither do I.

OTOH, I don't remember ever using one...

--
Thanks,
Fred.
Reply to
Fred Bartoli

with the free code space?

You're just a bit over 10 years too late :>

formatting link

Reply to
D Yuniskis

On a sunny day (Wed, 19 May 2010 13:01:31 -0700) it happened D Yuniskis wrote in :

with the free code space?

No, that one is connected via a serial port probably PPP, mine has a real ethernet RJ45 connection. There is a PIC with build in Ethernet controller but in one of those tiny packages. I use the 18F14K22 PIC and a ENC28J60 controller, both DIL, making it much easier to put together a quick veroboard thing. That iPIC TCP/IP stack sounds interesting though, as some services, for example Vodafone, seem to block UDP packets one way, probably stateful firewalls used against VOIP.

Reply to
Jan Panteltje

MAXIM chip, I have some,

chip you

hang

or buffer).

I'd love to try it out, but I'm an AVR guy - I wonder how difficult it would be to port the code to use on something like an ATMega168....

Reply to
Bitrex

ET

ye=3D

AXI=3D

I've killed at least one with a large ESD blast. Another got nailed by a miswire.

llw=3D

It could even say "The manual is at

formatting link
"

Reply to
MooseFET

Considering how awful the PIC is, that could take a while :)

I don't entirely like the AVR instruction set. 200+ instructions and hardly any of them do anything, in and of themselves. Any basic operation requires two or more (load, modify, store). So as nice as it is, it's tedious to use. Despite the tedium, it's definitely easy to use.

It's got gobs of registers, flat address space and lots of RAM (ATmega32 =

1k RAM, 512 EEPROM, 32k Flash). If it had a rich instruction set closer to Z80 or HC11 or something like that, and came with a macro assembler, I wouldn't need anything else.

Tim

--
Deep Friar: a very philosophical monk.
Website: http://webpages.charter.net/dawill/tmoranwms
Reply to
Tim Williams

I'm not entirely clear from the OP whether just the SPI protocol is implemented in assembly, or if the entire program is assembly. Assuming the ATMega has a working SPI bus if the rest of the code is in C one would probably just have to modify things like I/O port assignments and interrupt timing/handling. If it's all assembly, well then one might be better off just writing it from scratch...:)

Atmel sez:

"Many people believe RISC is an acronym for "Reduced Instruction Set Computer", and that a RISC must have a limited number of instructions. But those familiar with the history of how the terms RISC and CISC were coined will know that RISC is an acronym for "Reduced COMPLEXITY Instruction Set Computer". But because RCISC didn't sound very elegant, the acronym RISC was applied to the theory. It is not the number of instructions that is reduced in the AVR instruction set; what is reduced is the complexity of the digital circuitry required to decode each instruction...

blah blah blah

Following countless iterations, the AVR architecture became optimized for C-code execution, with bottlenecks completely eliminated during the construction phase."

So essentially it seems the instruction set is what it is because they figured everyone is going to be programming these things in C anyhow, so they created the instruction set with that in mind. I'm fine with that because personally I like abstraction and enjoy working in assembly about as much as a soldering iron in the eye. Ever messed around with a PDP-8? I'm not old enough to have used the real thing, but I wrote a little emulator in Python. It had a tight instruction set - just 6 base operations!

Speaking of abstraction and Python, I just ordered an ATMega644 to see if I could get Python running on it via PyMite.

Reply to
Bitrex

On a sunny day (Wed, 19 May 2010 19:10:24 -0400) it happened Bitrex wrote in :

a MAXIM chip, I have some,

chip you

hang

or buffer).

I dunno, I wrote it in PIC 18 asm :-) But before that I wrote some test routines for the ENC28J60 Ethernet controller in C:

formatting link
I could have used compiler I guess, but I do not like C on such small micros. (256 byte RAM). So I rewrote it in asm... And added some I/O features, streaming too. You can for example use the serial port, and stream audio: cat my_music.mp3 > /dev/ttyS0 will stream UDP to port and Ip specified in the asm file. Other end can do: netcat -u -l -p 1024 | mpg123 -a /dev/dsp0 - I am not sure, and for sure not ready ,to release this asm code as open source, I think it is worth real money as a solution too.

Or you can start a second netcat on the remote PC like this: netcat -u MY_IP 1024 and set digtal outputs, read digital inputs (via the first netcat), read analog values, and set a PWM output (now controls a LED brightness).

The C code is GPL, so all it does is initialise the ethernet controller, send ARP request to find the MAC of the destination, or gateway, and go into a loop reading UDP packets and processing those, and reading stdin and sending that in UDP packets.

Reply to
Jan Panteltje

On a sunny day (Wed, 19 May 2010 17:17:17 -0700 (PDT)) it happened MooseFET wrote in :

Na, jaaa, lightning...

Reply to
Jan Panteltje

I always use the CDP1802 as the reference for awful instruction sets.

A =3D B + C

needs 16 instructions in an 1802. Compared to it, the PIC is not too bad.

The 8051 has a fairly nice instruction set in that it does a lot of the things that you want a microcontroller to do with just one or perhaps

2 instructions.

ardly

uires

o

The AVR does have an OK instruction set but it isn't really correct to call it a RISC. It has a largish instruction set.

Reply to
MooseFET

On a sunny day (Thu, 20 May 2010 06:11:31 -0700 (PDT)) it happened MooseFET wrote in :

The PIC 18F has an 8 bit hardware multiplier So for A7:A0 x B7:B0 -> C15:C0 in one instruction

It also has very nice compares: cpfseq compare register F with accumulator, skip next instruction if equal spfsgt same, but less than cpfslt same, but greater then

Saves testing status register zero flag, carry, etc.

I have used these a lot, have not used the hardware multiply, could be nice for some filters.

And of course all the bit set, bit clear, and bit test instructions on any register or RAM location. Suits me well.

Reply to
Jan Panteltje

On a sunny day (Thu, 20 May 2010 14:16:47 GMT) it happened Jan Panteltje wrote in :spfsgt same, but less than

Oops, other way around of course :-)

Reply to
Jan Panteltje

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.