Stumped with word variable


Closed Thread
Results 1 to 31 of 31

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,705


    Did you find this post helpful? Yes | No

    Default Re: Stumped with word variable

    it might be easier to use a PCF8563 rtc chip with built in alarm and interrupt output
    I use one of these on my wireless remote rain guage its a good thing. works at 3v too

    i'd need to see the full code to see whats wrong with your project

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: Stumped with word variable

    Hi,
    I have NO idea what's going on with this Illegal Character error. The only thing I can think of is, as I've said before, some kind of hidden character that makes the compiler hick up. I copy/pasted all of the sections in the previous post into MCS, resulting in the following:
    Code:
    Blue_On_Time_H var byte
    Blue_on_Time_M var byte
    Blue_Off_Time_H var byte
    Blue_off_Time_M var byte
    
    White_On_Time_H var byte
    White_on_Time_M var byte
    White_Off_Time_H var byte
    White_off_Time_M var byte
    
    data    14      'Blue ON time hours
    Data    00      'Blue ON time minutes
    data    15      'Blue OFF time hours
    Data    00      'Blue OFF time minutes
    Data    14      'Whites ON time hours
    data    01      'Whites ON time minutes
    data    14      'Whites OFF time hours
    Data    20      'Whites OFF time minutes
        
    write 10,white_on_time_h              'Whites ON time hours
    write 11,white_on_time_m              'Whites ON time minutes
    write 12,white_off_time_h             'Whites OFF time hours
    write 13,white_off_time_m             'Whites OFF time minutes
    write 14,blue_on_time_h             'Whites ON time hours
    write 15,blue_on_time_m             'Whites ON time minutes
    write 16,blue_off_time_h            'Whites OFF time hours
    write 17,blue_off_time_m            'Whites OFF time minutes
    
    Read 10,white_on_time_h              'Whites ON time hours
    Read 11,white_on_time_m              'Whites ON time minutes
    read 12,white_off_time_h             'Whites OFF time hours
    read 13,white_off_time_m             'Whites OFF time minutes
    read 14,blue_on_time_h             'blue ON time hours
    read 15,blue_on_time_m             'blue ON time minutes
    read 16,blue_off_time_h            'blue OFF time hours
    read 17,blue_off_time_m            'blue OFF time minutes
    
    END
    Needles to say it compiles just fine for the 12F683, 16F877, 18F8620 and any other device I try with onboard EEPROM. I've tried this with both PBP3.0.7.4 and with PBP2.60. My MPBLAB installation is v8.88 containing MPASM v5.47.

    /Henrik.

  3. #3
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: Stumped with word variable

    Richard, you have a PM

    @Henrik - I too have no idea why the error occurs - I've cut and pasted lines, written them in fill - deleted sections and pasted sections - but still the same ! - Puzzling

  4. #4
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: Stumped with word variable

    Quote Originally Posted by HenrikOlsson View Post
    Hi,
    I have NO idea what's going on with this Illegal Character error. The only thing I can think of is, as I've said before, some kind of hidden character that makes the compiler hick up. I copy/pasted all of the sections in the previous post into MCS, resulting in the following:
    Code:
    Blue_On_Time_H var byte
    Blue_on_Time_M var byte
    Blue_Off_Time_H var byte
    Blue_off_Time_M var byte
    
    White_On_Time_H var byte
    White_on_Time_M var byte
    White_Off_Time_H var byte
    White_off_Time_M var byte
    
    data    14      'Blue ON time hours
    Data    00      'Blue ON time minutes
    data    15      'Blue OFF time hours
    Data    00      'Blue OFF time minutes
    Data    14      'Whites ON time hours
    data    01      'Whites ON time minutes
    data    14      'Whites OFF time hours
    Data    20      'Whites OFF time minutes
        
    write 10,white_on_time_h              'Whites ON time hours
    write 11,white_on_time_m              'Whites ON time minutes
    write 12,white_off_time_h             'Whites OFF time hours
    write 13,white_off_time_m             'Whites OFF time minutes
    write 14,blue_on_time_h             'Whites ON time hours
    write 15,blue_on_time_m             'Whites ON time minutes
    write 16,blue_off_time_h            'Whites OFF time hours
    write 17,blue_off_time_m            'Whites OFF time minutes
    
    Read 10,white_on_time_h              'Whites ON time hours
    Read 11,white_on_time_m              'Whites ON time minutes
    read 12,white_off_time_h             'Whites OFF time hours
    read 13,white_off_time_m             'Whites OFF time minutes
    read 14,blue_on_time_h             'blue ON time hours
    read 15,blue_on_time_m             'blue ON time minutes
    read 16,blue_off_time_h            'blue OFF time hours
    read 17,blue_off_time_m            'blue OFF time minutes
    
    END
    Needles to say it compiles just fine for the 12F683, 16F877, 18F8620 and any other device I try with onboard EEPROM. I've tried this with both PBP3.0.7.4 and with PBP2.60. My MPBLAB installation is v8.88 containing MPASM v5.47.

    /Henrik.
    Just created a new blank page in MCS and copied and pasted the above from post #17, added the config settings etc and tried compiling

    Code:
    '*******************************************************************************
    '  18F4520 config settings - for use with MPSAM
    '*******************************************************************************
    
    ASM 
      __CONFIG    _CONFIG1H, _OSC_HS_1H
      __CONFIG    _CONFIG2L, _PWRT_ON_2L  
      __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
      __CONFIG    _CONFIG3H, _MCLRE_ON_3H & _LPT1OSC_OFF_3H & _PBADEN_OFF_3H  
      __CONFIG    _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
    ENDASM
    
    '*******************************************************************************
    ' Defines and LCD (20 x 4) set up
    '*******************************************************************************
    
    DEFINE  OSC 20  ; 48 was old config settings 18F4520, 20mhz crystal
    ADCON1 = $0F
    clear
    
    DEFINE  WRITE_USED  1
    
    DEFINE LCD_DREG  PORTB           ' LCD Data port
    DEFINE LCD_DBIT  0               ' starting Data bit (0 or 4)
    DEFINE LCD_EREG  PORTB           ' LCD Enable port
    DEFINE LCD_EBIT  5               '     Enable bit  (on EasyPIC 5 LCD)
    DEFINE LCD_RSREG PORTB           ' LCD Register Select port
    DEFINE LCD_RSBIT 4               '     Register Select bit   (on EasyPIC 5 LCD)
    DEFINE LCD_BITS  4               ' LCD bus size (4 or 8 bits)
    DEFINE LCD_LINES 4               ' number of lines on LCD
    DEFINE LCD_COMMANDUS 2000        ' Command delay time in us 
    DEFINE LCD_DATAUS 50             ' Data delay time in us 
    
    '*******************************************************************************
    'DS18B20 setting
    '*******************************************************************************
    
    DQ              VAR     PORTA.5         ' One-wire data pin
    temperature     VAR     WORD            ' Temperature storage
    count_remain    VAR     BYTE            ' Count remaining
    count_per_c     VAR     BYTE            ' Count per degree C
    
    '*******************************************************************************
    'analog and Comparator settings
    '*******************************************************************************
    
    ADCON0 = 0                      'Set ADCON0
    ADCON1 = %00001111              'Set D i/o
    CMCON = 7                       'Disable Comparators
    
    '*******************************************************************************
    'Port and Register settings
    '*******************************************************************************
    
    CCP1CON = %00001100             ' 
    CCP2CON = %00001100             '     
    TRISA  = %11101111              '
    TRISB  = %00000011 
    TRISD  = %00000011              '
    T0CON  = %11000111
    
    Blue_On_Time_H var byte
    Blue_on_Time_M var byte
    Blue_Off_Time_H var byte
    Blue_off_Time_M var byte
    
    White_On_Time_H var byte
    White_on_Time_M var byte
    White_Off_Time_H var byte
    White_off_Time_M var byte
    
    data    14      'Blue ON time hours
    Data    00      'Blue ON time minutes
    data    15      'Blue OFF time hours
    Data    00      'Blue OFF time minutes
    Data    14      'Whites ON time hours
    data    01      'Whites ON time minutes
    data    14      'Whites OFF time hours
    Data    20      'Whites OFF time minutes
        
    write 10,white_on_time_h              'Whites ON time hours
    write 11,white_on_time_m              'Whites ON time minutes
    write 12,white_off_time_h             'Whites OFF time hours
    write 13,white_off_time_m             'Whites OFF time minutes
    write 14,blue_on_time_h             'Whites ON time hours
    write 15,blue_on_time_m             'Whites ON time minutes
    write 16,blue_off_time_h            'Whites OFF time hours
    write 17,blue_off_time_m            'Whites OFF time minutes
    
    Read 10,white_on_time_h              'Whites ON time hours
    Read 11,white_on_time_m              'Whites ON time minutes
    read 12,white_off_time_h             'Whites OFF time hours
    read 13,white_off_time_m             'Whites OFF time minutes
    read 14,blue_on_time_h             'blue ON time hours
    read 15,blue_on_time_m             'blue ON time minutes
    read 16,blue_off_time_h            'blue OFF time hours
    read 17,blue_off_time_m            'blue OFF time minutes
    Guess what - I got the error

    If I comment out the write statements it compiles....

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: Stumped with word variable

    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.

  6. #6
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: Stumped with word variable

    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

  7. #7
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: Stumped with word variable

    Could you explain to me what this define means or does, and when it might be used.
    No, not really. That's why I asked where you found it and what the reason for adding it was.

    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.

  8. #8
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: Stumped with word variable

    Thanks Henrik, I'll have a browse and look at my options to upgrade.

    Malcolm

  9. #9
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: Stumped with word variable

    I've been re-reading the reference guide and this may explain it:

    If 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
    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 interrupts

  10. #10
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: Stumped with word variable

    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...

  11. #11
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: Stumped with word variable

    Quote Originally Posted by richard View Post
    it might be easier to use a PCF8563 rtc chip with built in alarm and interrupt output
    I use one of these on my wireless remote rain guage its a good thing. works at 3v too

    i'd need to see the full code to see whats wrong with your project
    I have a DS1307 RTC chip, but for some reason in the original project this gave me a lot of issues as the time would randomly revert to 10:10:10 and thus screw up the timings. I'll have a look at the 8563 chip, but really wanted to steer away from external chips in case the same issue happens again

  12. #12
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: Stumped with word variable

    What if you start a new/blank project/file, then copy/paste the complete code from my latest post above into it, select the 12F683 (for example) and then try to compile it. Does it still give you the error?

    If this STILL fails can you then please take the source file (the .pbp or .bas file) and attach it to a message here so I can try and compile it on my end. There's got to be something weird going on with your system, I can not make it fail here PBP3 with MPASM or PBP2.60 with MPASM or PM (for 12F and 16F parts) it all works fine with the above code.

    Which chip are you compiling for?

    /Henrik.

  13. #13
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: Stumped with word variable

    Henrik, I'll try that suggestion later and let you know how I get on. The chip is an 18F4520

  14. #14
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: Stumped with word variable

    OK, then PM is out of the question and the only difference between your setup and mine is MPLAB 8.87 vs 8.88 and whatever MPASM version that translates too - there might not even be a different version.

    Just tried compiling for 18F4520 using PBP2.60 and there was no errors.

    Looking forward to the results.

    /Henrik,

Similar Threads

  1. When variable may not fits into WORD limitations
    By CuriousOne in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 16th July 2013, 10:26
  2. How to isolate 10 bits from word variable?
    By rcbandwidth123 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 14th April 2008, 21:18
  3. adding new word variable ?
    By iugmoh in forum General
    Replies: 4
    Last Post: - 21st February 2008, 01:26
  4. WORD vs BYTE variable lengths
    By bartman in forum General
    Replies: 0
    Last Post: - 28th November 2005, 22:16
  5. word variable to 25lc640
    By TONIGALEA in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 6th July 2004, 20:59

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts