Show Posts
Pages: 1 ... 3 4 [5] 6 7 ... 582
61  Using Arduino / Programming Questions / Re: How to use unsigned char arrays with external SRAM? on: April 15, 2014, 06:48:24 am
Jeez I'm confused and I know nothing about TinyBasic, but if you have two arrays of data, one in the AVR RAM and the other in external RAM write a loop that scans the AVR array and compares it with the external array, one byte at a time, similar to what you did in the first post.

You cannot use the = operator (well you could if you overload it but that's out of your league I think).

Quote
only if TinyBASIC would still work by using this method which I am not sure about)
What does TB have to do with this? Is this a C question or a TB question? Does the code have to be written in TB?

Quote
need a method to make an internal array equal the external SRAM array without bringing the data in
Now I'm even more confused, do you want to move the AVR data to the external RAM (or VV)?

______
Rob
62  Products / Arduino Due / Re: Anyone using CMSIS? How to get started? on: April 14, 2014, 06:44:45 pm
I've done quite a lot of programming on LPCs (great chips and environment BTW) and I confess that I'm still not 100% sure how useful CMSIS is. Yes it's supposed to be an abstraction layer for the ARM, but how many people actually work with the ARM core? Answer, almost none.

Here is a snippet from my main() func

Code:
// Enable AHB clock for GPIO ports
LPC_SYSCON->SYSAHBCLKCTRL |= _BV(AHB_GPIO1) | _BV(AHB_GPIO0);

The definitions here are from an H file in the CMSIS folder, but this is very LPC specific, no way that code will run on a SAM or ST. So there is a small abstraction level there but not much and certainly not portable.

Here is some more setup code

Code:
LPC_SYSCON->SYSOSCCTRL = 0;
LPC_SYSCON->PDRUNCFG &= ~(1 << 5);
LPC_SYSCON->SYSOSCCTRL = 1;

This is obviously dealing with the ARM core which will be the same on all M0 chips, but the left values at least have an LPC_ prefix so once again this code won't work on another family, even is if all boils down to the same address, offsets and code.

And this is working directly with the M0 core, almost nobody does that except maybe a little setup code, most code is either generic C/C++ that will run anywhere or deals with the chip's peripherals which are totally different on all families.

So for the average user I see almost no benefit to CMSIS, they need a real HAL framework like the Arduino.

Quote
NXP gets points for removing restrictions on the free version of their LPCXpresso IDE, namely C++ support is now included, and code size limitations eased or removed.
Yes, I ported most of the Arduino core to LPC122x, but that was before they opened up the compiler and I had to do it all in C so things like Serial.begin() had to be SerialBegin() etc. I got it to the stage where you could run a simple Arduino sketch with very few changes to the code.

Now that C++ is free I've started porting the code to C++. I haven't got far with the conversion though because I have too many other things to do.

______
Rob
63  Using Arduino / Project Guidance / Re: multiple devices on one serial port? on: April 14, 2014, 10:04:03 am
Quote
the devices are all the same and send their data once every second  at 9600baud. i have no influence on these devices except for powering them on and off.
Then you are out of luck, there are many ways to do this with a single serial port but they all require you to write a protocol that runs on all connected devices, as you have no control over most of them there's little you can do except have a heap of serial connections or control the power to each device and cycle through them.

As for using software serial, I don't think it works well (at all?) with 10 inputs.

______
Rob
64  Development / Other Hardware Development / Re: Arduino shield pins and ICSP header mismatched height on: April 14, 2014, 09:24:40 am
I often wondered how well that SPI header worked as it's pins are a different length to those on the shield pass-through headers.

______
Rob
65  Using Arduino / Networking, Protocols, and Devices / Re: Communicate between microcontrollers: Automatic address and request-less send? on: April 14, 2014, 08:20:09 am
Quote
So that leaves serial, CAN or RS485...but daisy-chaning makes it a bit unreliable. Especially if I want to use a ATTiny without a crystal the chance an error occurs along the path is high...So that leaves CAN or RS485.
CAN and RS485 are serial, they are just transceivers for the data to/from the UART (unless you use a CAN controller), so if you aren't happy with using "serial" then using RS485 won't make any difference from a timing point of view, it will help with long cables though.

Quote
Haven’t looked if there are Arduino libraries available for it,
As I say, RS485 is just a hardware buffer, it has nothing to do with the the protocol, so the standard serial function is all you need. CAN is (or can be) the same.

How about all nodes control an open-collector "pressed" signal, when a button is pressed you test this signal, if it's not asserted you pull it low and that locks out all the other nodes. You then transmit the node address etc. There is still a tiny race condition but in this application that can be ignored I think.

This would need an extra wire though.

______
Rob
66  Products / Arduino Due / Re: Small-footprint Due on: April 14, 2014, 07:01:48 am
Any chance of a schematic, it's hard to tell much from the PCB, for example why do you have 5v pins?

______
Rob
67  Using Arduino / Project Guidance / Re: output voltage of Atmega328 on: April 14, 2014, 04:07:42 am
Quote
Are the operating voltage and the output voltage of Atmega328 same?
Yes, there maybe a gnat's fart difference but for normal use consider them to be the same.

______
Rob
68  Development / Other Hardware Development / Re: List of tools for surface mount work on: April 14, 2014, 12:26:20 am
Quote
all I have to do is to add solder paste to the pads, place MCU, attach proper nozzle, and heat up, right?
Correct, plus maybe use solder wick to remove any bridges on fine-pitch chips.

I've not done the soldering iron drag trick, dunno if that's easier or not, but certainly using hot air is pretty easy although you have to be careful not to blow parts across the board smiley

______
Rob
69  Using Arduino / Project Guidance / Re: "External" memory for program memory? on: April 14, 2014, 12:16:36 am
I can't find the definition for the cor_canalX objects but if you had them in an array the desenhar_barras_periodo() function could be reduced to something like this

Code:
void desenhar_barras_periodo () {
int x = (setor_selecionado * 38)+5;
int y = (setor_selecionado * 38)+39

for (int i = 1; i < 5; i++) {
if (bitRead(cor_selecionada,i) == true) {
myGLCD.setColor(cor_canals[i][0], cor_canals[i][1],cor_canals[i][2]);
myGLCD.drawRect(x, 80, y, 195);
desenhar_barras(cor_canals[i][0], cor_canals[i][1], cor_canals[i][2], x, 80, y, 195);
}
}
}

______
Rob
70  Using Arduino / Networking, Protocols, and Devices / Re: Communicate between microcontrollers: Automatic address and request-less send? on: April 13, 2014, 07:13:59 pm
Quote
Another option I thought of is to use the serial communication to communicate with each other. The RX is connected to the TX of the other controller and so on.
That would probably be my approach, I assume you are happy to use serial rather than I2C.

The only down side is determining the order in which buttons are pressed, for example if a button on node 2 is pressed just before one on node 22 the master will still see the press from 22 first.

Is this a problem with your application?  If it's a game where the first button pressed wins then maybe.

As for the addresses, you can have a simple self-discovery algorithm that sends 0 to the first node, it records that as it's address, increments the number and passes it along. When the number returns all nodes have a unique address and you also know how many there are.

Also what is the distance between these boxes, I2C is not normally good for long runs.

______
Rob
71  Using Arduino / Programming Questions / Re: Help with modulo. 25%10 always rounds off to 6. on: April 13, 2014, 06:53:37 pm
No that's ok, you can call functions from anywhere, loop() is already called from main() so every time you do (for example) a Serial.print() inside loop() you are already calling a function from inside a function, and for all you know Serial.print() calls 10 other functions all of which call other functions again.

Subject to the stack overflowing there is no limit.

It seems that erdiegange's code works for everyone else, so the only unknown is the updateDisplay() function.

______
Rob
72  Using Arduino / Project Guidance / Re: Nested interrupts using NOBLOCK on: April 13, 2014, 06:35:37 pm
Quote
Another thing that could be done is to move the parsing function outside the ISR...
That is the recommended method and the "party line" on this forum. I don't necessarily follow the party line because all situations are different and it can make sense to have a lot of code in an ISR, after all if there is nothing else to do why not?

Maybe you should look at your timing to see if it's worth the risk of enabling nested interrupts, if the data is coming in at 300 baud you have about a week and a half to parse the packet before the next character comes in anyway.

I have to say though that in this case I will follow the party line, I think the ISR should just add chars to a FIFO and the main code should take chars from that FIFO and parse as required. That is a simple and compartmentalised interface.

Quote
What about noblock and Priority handling?
I've never heard of noblock so can't comment on that. The priority of interrupts is as per their order shown in the data sheet, and as I said before if you enable interrupts in the ISR then they will be handled, but if you are both adding and removing bytes from a FIFO you have to be very careful about all non-atomic instructions that deal with global elements of the FIFO, head and tail pointers are probably OK in themselves but any operations that use both have to be protected and as do things like counters that hold the number of bytes in the FIFO.

As for malloc(), are all the blocks the same size? If so why not just have an array of arrays for the data? If not how will you free the blocks without getting fragmentation?

If you have a FIFO of pointers to arrays there is no need to move data around at all, in general you try to avoid physically moving bytes, it's better to change a pointer.

______
Rob

73  Using Arduino / Project Guidance / Re: Nested interrupts using NOBLOCK on: April 13, 2014, 08:51:32 am
On an AVR if you enable interrupts inside an ISR they will be handled when they occur according the their priority. As there is just a single flag controlling the interrupt enable ALL interrupts that occur will be handled, possibly even the one you are already handling if that occurs again.

______
Rob
74  Products / Arduino Due / Re: 5100 ethernet and Due on: April 13, 2014, 08:09:29 am
I think so, do you see a "remove" button?

______
Rob
75  Products / Arduino Due / Re: 5100 ethernet and Due on: April 13, 2014, 07:41:59 am
All those definitions (DDRB, PORTB etc) are AVR-specific, they will not work on a Due. More than that I can't say because I've not used those libs.

BTW, why two posts?

______
Rob
Pages: 1 ... 3 4 [5] 6 7 ... 582