Hi,
Waste may not have been the best word. What I mean is that the string for each command is static, they don't change, so there's no real need for them to live in RAM - which they'll do if you follow option 1 in my previous post. Again, there's nothing inherently wrong with this and it might be the easiest way if you have the RAM to spare.Why does it "waste" RAM? Could it be stored in ROM instead?
It IS stored in ROM (FLASH actually) when you do it likeWhich means that option 2 does, obviously, use less amount of RAM.Code:HESEROUT [$55, $AA, $01, $FF, $00, $00, $AA, $56]
With PBP3 there are ways to create unique usercommands but it's a pretty advanced topic. With the information given so far I'd go for option 2. Create a subroutine for each of the 24 commands and call them in sequence using GOSUB.
/Henrik.
EDIT: And if you DO go for option 2 and want to save some codespace you could probably do that by creating a "send header" and a "send footer" sub so you don't need to store the same 4 bytes for each command 24 times.EDIT2: And now, if you use an 18F part and have LONGs enabled you COULD possibly do something like:[code]Code:mcuStop: GOSUB SendHeader : HESEROUT [$01, $FF, $00, $00] : GOSUB SendFooter RETURN SendHeader: HSEROUT [$55, $AA] RETURN SendFooter: HSEROUT [$AA, $56] RETURN
Watch out for Little vs big endian, I'm not sure, off the top of my head how it's being sent here so you may need to reverse it.Code:Header CON $55AA Footer CON $AA56 MotorStop CON $01FF0000 mcuStop: GOSUB SendHeader : HESEROUT [MotorStop] : GOSUB SendFooter RETURN SendHeader: HSEROUT [Header] RETURN SendFooter: HSEROUT [Footer] RETURN




Bookmarks