Hi,
OK, so there was a lot more to the code than you showed earlier....
The actual problem seems to be the DEFINE WRITE_USED 1. Comment that out and it compiles fine.ything. Where did you find that and what's the purpose of it?
/Henrik.
Hi,
OK, so there was a lot more to the code than you showed earlier....
The actual problem seems to be the DEFINE WRITE_USED 1. Comment that out and it compiles fine.ything. Where did you find that and what's the purpose of it?
/Henrik.
I can confirm that when that is commented out it too compiles fine this end. I have no Idea where that came from, I guess that's the problem when using previous code from existing projects or porting examples from forums and websites. Chances are a previous project required this for some reason, but with out opening every file I can't say where it came from.
Thanks for identifying this problem. Could you explain to me what this define means or does, and when it might be used.
I'll now go back over this thread and see if using the highbyte and lowbyte resolves my other issue of the case statement not changing when the blue on time value matches that of the current clock counter.
Malcolm
No, not really. That's why I asked where you found it and what the reason for adding it was.Could you explain to me what this define means or does, and when it might be used.
A bit of forum search turned up a couple of leads, apparently there's a bug in 2.60 which affects WRITE with WORD variables. But now, you might be on a later version of PBP where that bug is not present making the DEFINE either not needed or actually causing problems. I can't really say for sure.
The issue is described here.
I strongly suggest you update to 2.60C (or even better to PBP3), you can download the PBP2.60C patch here, scroll down to find 2.60C:
http://support.melabs.com/content/29...ersion-History
Someone else might be able to shed some more light on it.
/Henrik.
Thanks Henrik, I'll have a browse and look at my options to upgrade.
Malcolm
I've been re-reading the reference guide and this may explain it:
I'm not using interrupts in this code, so it's not needed - I must of added from one of the previous versions which does use interruptsIf interrupts are used in a program, they must be turned off (masked, not
DISABLEd) before executing a WRITE, and turned back on (if desired) after the
WRITE instruction is complete. An interrupt occurring during a WRITE may cause
it to fail. The following DEFINE turns interrupts off and then back on within a
WRITE command. Do not use this DEFINE if interrupts are not used in the
program.
DEFINE WRITE_INT 1
Richard / Henrik
Code is now working. This is the data section
Then the read statementCode:'******************************************************************************* ' Data presets '******************************************************************************* data @0 data 00 'Blue fade IN duration hours data 30 'Blue fade IN duration minutes data 00 'Blues fade OUT duration hours data 30 'Blue fade OUT duration minutes data 00 'Whites fade IN duration hours data 30 'Whites Fade IN duration MINS data 00 'Whites Fade OUT duration HOURS data 30 'Whites Fade OUT duration MINS data 255 'Blue MAX Intensity % data 255 'Whites MAX Intensity % data word 842 'Blue ON time Data word 841 'Whites ON time data word 1200 'Blue OFF time Data word 1200 'White OFF time
I then have a simple test line ofCode:Read 0,fadesetHR[0] 'Blue fade IN duration hours Read 1,fadesetMN[0] 'Blue fade IN duration minutes Read 2,fadeoutHR[0] 'Blue fade OUT duration hours read 3,fadeoutMN[0] 'Blue fade OUT duration minutes read 4,fadesetHR[1] 'Whites fade IN duration hours read 5,fadesetMN[1] 'Whites fade IN duration minutes read 6,fadeoutHR[1] 'Whites fade OUT duration hours read 7,fadeoutMN[1] 'Whites fade OUT duration minutes Read 8,B_max Read 9,W_max read 10,Blue_on_Time.lowbyte read 11,Blue_on_Time.highbyte read 12,white_on_Time.lowbyte read 13,white_on_Time.highbyte read 14,Blue_off_Time.highbyte read 15,Blue_off_Time.lowbyte read 16,white_off_Time.lowbyte read 17,white_off_Time.highbyte Return
This shows the value for Blue_on_time as 842, and the counter starting at 840 as per the data statement. When the counter reaches 842 the case statement changes as required.Code:lcdout $FE,$D4+11,dec Counter1 lcdout $FE,$D4+16,dec Blue_on_Time
Thank you both, and I apologise for putting you guys to so much trouble having tested parts of the code on various chips. Your guidance and input on my posts have been much appreciated
Malcolm
An alternative to using high/lowbyte for a word is to shift bits within the word
Some code might be pseudo
This is helpful if you want to use variables larger than PBP supportsCode:word var word byte var byte DATA at EEPROM location 0 = $FF // low byte of the word you want to read DATA at EEPROM location 1 = $FF // high byte of the word you want to read // program run time READ EEPROM, 0, byte word = byte word = word << 8 READ EEPROM, 1,byte word = word + byte // now the word is in memory - word = $FFFF byte = word WRITE EEPROM 0,byte word = word >> 8 byte = word WRITE EEPROM 1,byte // the value in word was not preserved here, // it would have been needed to be saved first
for some operations.
It would be simple to do a binary addition on two 64 bit integers this way,
and is more familiar outside of BASIC.
When applying the patch it looks like it's replacing all the .inc files so if you've edited ANY of them they will have to be re-editied.
/Henrik.
Last edited by HenrikOlsson; - 10th November 2013 at 20:02. Reason: Double post...
Bookmarks