Menu

Problem: Variable PORTB was not explicitly declared

3 days ago
3 days ago
  • Lewis Whitacre

    Lewis Whitacre - 3 days ago

    I am a Noobie feeling my way around. New GC Studio installation/latest version.

    Used: first-start-sample.gcb

    Added #option Explicit

    No errors were reported using #CHIP 16f886
    Changed to an old PIC part in hand. #CHIP 12f675

    [{
       Line 42 PulseOut PortB.5, 100 ms
    
        "resource": "/c:/GCstudio/gcbasic/demos/first-lew-test.gcb",
        "owner": "gcb",
        "severity": 8,
        "message": "Variable PORTB was not explicitly declared",
        "source": "gcb",
        "startLineNumber": 42,
        "startColumn": 1,
        "endLineNumber": 42,
        "endColumn": 2147483647
    }]
    

    Best regards,
    Lew

     
  • Angel Mier

    Angel Mier - 3 days ago

    hi Lewis and welcome.
    in deed the compiler is telling you that this part (pic 12f675) didn't have a port B (it's a tinny pic with only 6 IO pins) when you read the datasheet of that part you can see that those pins are called GP0, GP1, GP2, GP3, GP4 and GP5. you can use this designations in GC basic, so for example you can use:

    dir GP1 out
    
    do forever
       GP1 = 1
       wait 1 s
       GP1 = 0
       wait 1 s
    loop
    

    to blink a led on pin 6

    happy coding!

    Angel

     
  • Lewis Whitacre

    Lewis Whitacre - 3 days ago

    Dang! Embarrassed. I knew that...ahem, more than 10 years ago!

    Thank you Angel.

     

Log in to post a comment.