Advice please - Warning message


Closed Thread
Results 1 to 40 of 51

Hybrid View

  1. #1
    malc-c's Avatar
    malc-c Guest

    Default Advice please - Warning message

    Hi guys and gals,

    I'm playing with PBP and the 18F2550 pic (as I had one to hand), and just trying to do some basic LED flashing as a start for a new version of an old project.

    I've downloaded the latest patch for PBP 2.46, and the latest version of Microcode studio. I'm also using MPASM (I've used MPLA 7.31 as I've just re-ghosted the PC and that was what was on it at the time I made the ghost image )

    I've ported some code I used for a previous vesion of this project based on a 16F628a into a blank page in microcode studio and compiled it. It through out several warnings, which with the help of the search function of this forum I've resolved by editing the INC file. However it now compiles fine, but shows a warning.

    I know that warnings don't affect the operation of the code, but I would like to know what it means so as to further my knowledge. I'm still a noobe when it comes to working with different chips and although I've looked at the datasheet it still makes little sence. I assume that its because the 18F has a different number of bits in its words or something ??

    Anyway, here's the code

    Code:
    ;************ set up PIC *****************
    PORTA = 0                        ' declare port level BEFORE port direction = safe power-on
    CMCON = 7                        ' PortA Digital inputs
    CCP1CON = 0                      ' PWM off
    
    
    
    TRISA=%11100111                  'set PORTA as all input apart from A3 & A4
    TRISB=%00000000                  'set PORTB as all output
    
    @RC_OSC_NOCLKOUT 
    @WDT_ON
    @PWRT_ON
    @MCLR_OFF
    @BOD_ON
    @LVP_OFF
    @CPD_OFF
    @PROTECT_OFF
    
    ;************* set up pattern data **********
        
    Patt1 DATA 16,1,2,4,8,16,32,64,128,128,64,32,16,8,4,2,1 
    Patt2 DATA 8,129,66,36,24,24,36,66,129 
    Patt3 DATA 16,1,3,2,6,4,12,8,24,16,48,32,96,64,192,128,0 
    Patt4 DATA 16,1,128,2,64,4,32,8,16,8,32,4,64,2,128,1,0 
    Patt5 DATA 12,24,60,126,255,231,195,129,0,129,195,231,255 
    Patt6 DATA 13,1,2,4,8,17,34,68,136,16,32,64,128,0 
    Patt7 DATA 8,128,64,32,16,8,4,2,1
    
    ;************* set up varibles ************
        
    i var byte                          ;used for for next loops
    D var byte                          ;used to store the result of the pot on port A1 and thus set timing delay
    scale var byte                      ;used in the POT command
    Scale = 254                         ;used to set range 
    SW1 var PORTA.6                     ;pattern cycle switch 
    SW2 var PORTA.0                     ;select music or clock
    mus var PORTA.2                     ;music input pin A2
    SWcount var byte                    ;used to count the button SW1 presses
    SWcount2 var byte
    swcount=1                           ;set default to pattern 1
    steps VAR BYTE                      ;used to store the number of steps in the pattern sequence
    counts VAR BYTE                     ;used in the FOR NEXT loop to run through the sequence
                                                                
    ;************* main program ****************
    counts = 0                          ;set the value of counts to the start of each pattern
    
    Main:
    Pot PORTA.1,scale,D                 ;used to read value from 10k pot
    if sw1=0 then swcount=swcount+1     ;check to see if up button pressed, if so add 1 to SWcount
    if sw2=0 then goto music
    pause 60                            ;debounce delay
    If swcount>7 then swcount=1         ;error trap for exceeding max patterns                          
    gosub sel1                          ;go to subroutine to select pattern based on Swcount value
    FOR counts = 1 TO steps             ;advance to through the entries
    gosub sel2                          ;go to subroutine to advance through sequence
    PAUSE D                             ;pause period set by varible D
    NEXT counts                         ;advance through loop to next position                    
    goto main:                          ;go back to the main program and run again
    
    
    music:
    if sw1=0 then swcount=swcount+1     ;cycles through the patterns by adding 1 to SWcount
    pause 60                            ;debounce delay
    If swcount>7 then swcount=1         ;error trap for exceeding max patterns                        
    gosub sel1                          ;go to subroutine to select pattern based on SWcount value
    If mus = 1 then counts = counts + 1 ;if bass or beat present move to the next step in pattern 
    gosub sel2                          ;go to subroutine to display pattern in current step
    If counts = steps then counts = 0   ;if counts then reset counts to 1
    goto music:                         ;go back to the start of the music section 
    
    ;************* Subroutines *****************
    Sel1:
    if swcount = 1 then read Patt1, steps   ;read the first value in data string patt1 and place it in steps
    if swcount = 2 then read Patt2, steps
    If swcount = 3 then read Patt3, steps
    if swcount = 4 then read Patt4, steps
    if swcount = 5 then read Patt5, steps
    If swcount = 6 then read Patt6, steps
    If swcount = 7 then Read patt7, steps
    return
    
    Sel2:
    if swcount = 1 then READ (Patt1+counts), PORTB  ;read the next value in patt1 and display it on PORTB
    if swcount = 2 then READ (Patt2+counts), PORTB
    if swcount = 3 then READ (Patt3+counts), PORTB
    if swcount = 4 then READ (Patt4+counts), PORTB
    if swcount = 5 then READ (Patt5+counts), PORTB
    if swcount = 6 then READ (Patt6+counts), PORTB
    if swcount = 7 then READ (Patt7+counts), PORTB
    RETURN
    And this is the warning that I get after it compiles

    Code:
    warning[202] (path and file name).mac48: Argument out of range. Least significant bit used
    Last edited by malc-c; - 9th December 2006 at 22:16.

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Yup but it's just a Warning, it will work... at least a simple test worked here. So just add
    @ errorlevel -202

    somewhere at the top of your code to override the MPASM error message.

    The warning problem comes with the LABEL+Byte variable.

    maybe there's something to work around in the MACRO somewhere... bah it works.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default Its amazing how rusty I am after 6 months break

    OK, I've breadboarded the 18F2550, with 8 LEDs running off port B, 4Mhz xtal across pins 9 & 10 with 22pf caps to gnd. 10K pull up on pin1 (MCLR) and power to the vdd and vss pins - but the LEDS don't run.

    My logic tells me that I need to set port be to digital, but can't for the life of me work out how to.

  4. #4
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default Thanks

    Thanks steve, I've added the line and it compiles now without showing the warning message (as you stated it would )

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    And... it was easier to hack than i thought....
    Code:
    Sel2:
    if swcount = 1 then READ ((Patt1>>0)+counts), PORTB  ;read the next value in patt1 and display it on PORTB
    if swcount = 2 then READ ((Patt2>>0)+counts), PORTB
    if swcount = 3 then READ ((Patt3>>0)+counts), PORTB
    if swcount = 4 then READ ((Patt4>>0)+counts), PORTB
    if swcount = 5 then READ ((Patt5>>0)+counts), PORTB
    if swcount = 6 then READ ((Patt6>>0)+counts), PORTB
    if swcount = 7 then READ ((Patt7>>0)+counts), PORTB
    RETURN
    OR for less code generated solution
    Code:
    Sel2:
    if swcount = 1 then READ ((Patt1+0)+counts), PORTB  ;read the next value in patt1 and display it on PORTB
    if swcount = 2 then READ ((Patt2+0)+counts), PORTB
    if swcount = 3 then READ ((Patt3+0)+counts), PORTB
    if swcount = 4 then READ ((Patt4+0)+counts), PORTB
    if swcount = 5 then READ ((Patt5+0)+counts), PORTB
    if swcount = 6 then READ ((Patt6+0)+counts), PORTB
    if swcount = 7 then READ ((Patt7+0)+counts), PORTB
    RETURN
    Enjoy!

    For sure there's way to reduce the code size but i leave this in your hand

    teaser
    Code:
    Addr=Patt7+counts
    Read addr, PORTB
    Select case is another one, LOOKUP too.

    And you can configure PORTB as digital in your config fuses with the right setting
    Code:
    _PBADEN_OFF_3H      ; PORTB<4:0> pins are configured as digital I/O on Reset
    _PBADEN_ON_3H       ; PORTB<4:0> pins are configured as analog input channels on Reset
    OR use

    ADCON1=$0F
    CMCON=7
    Last edited by mister_e; - 10th December 2006 at 02:01.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Steve, thanks once again for your advice. I'm stunned at how rusty I've become in the past 6 months !

    Yes I dare say that the code could be made tidy and more condensed, but I tend to do things in my illogical way first as I can get my head around what is sposed to happen. Besides, its not as if I'm short for space in this chip but I should really get in the habbit of making tighter code.

    I'm hoping to have a play with the A/D convertion later by placing the input from a CD player into the PIC so that the LEDs act as a VU type meter, so no doubt will be asking lots more questions. I will of course try and code it first (only way to really learn), but I'm sure I'll still need advice, especially on the calibration as the input will be probably be less than 1v peak to peak, so any hardware suggestions between the PIC and CD player would be welcome

    Edit:
    The code already uses CMCON = 7 so how come the LEDs won't light. could it be down to the clock settings. The 16F628 used its internal clock.. the 18F2550 uses an external 4mhz xtal...
    Last edited by malc-c; - 10th December 2006 at 10:40.

  7. #7
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default OK I'm stummped

    I feel like I've experienced some form of memory loss and I'm having to learn how to ride a bike all over again !

    I've breadboarded the circuit as follows:
    Pin 20 = +5v
    Pin 19 and pin 8 = GND
    Pin 1 = +ve via a 10K resistor
    Pin 9 & 10 - 4 Mhz xtal with 22pf between pins and GND
    Pins 21 - 28 LED with 120 R resistor to GND

    When power is applied RB7, RB6, RB4 and RB3 faintly light and appear to be flickering randomly (like a candle effect)

    I'm getting 1.25v on the above pins, but RB5 is showing -1.1v, RB2 = -0.8 and -0.9v on RB1 and RB0

    Does the 2550 PIC require the USB components connect to RC4 -7 to function correctly ?

    EDIT:

    Can someone confirm that I have the correct settings in the application and INC files

    Program code
    Code:
    @WDT_ON
    @PWRT_ON
    @MCLR_OFF
    @BOD_ON
    @LVP_OFF
    @CPD_OFF
    @PROTECT_OFF
    @ errorlevel -202
    and INC file (in PBP folder)
    Code:
            INCLUDE "P18F2550.INC"	; MPASM  Header
            __CONFIG    _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
            __CONFIG    _CONFIG1H, _FOSC_HS_1H
            __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H
            __CONFIG    _CONFIG3H, _PBADEN_OFF_3H
            __CONFIG    _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
    Last edited by malc-c; - 10th December 2006 at 13:09.

Similar Threads

  1. PIC16F690 PBP boundary crossing warning message
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 9th May 2008, 11:17
  2. Micro Code Studio - Warning message
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 17th November 2006, 21:17
  3. MicroCode Studio Boundary Warning Message
    By coyotegd in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th March 2006, 09:13
  4. Message String Table using Readcode
    By mytekcontrols in forum Code Examples
    Replies: 2
    Last Post: - 10th July 2005, 23:17
  5. warning message
    By pic beginner in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 23rd July 2004, 02:53

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