Pic18 Syntax problem


Closed Thread
Results 1 to 4 of 4
  1. #1
    Philip Biebach's Avatar
    Philip Biebach Guest

    Default Pic18 Syntax problem

    hi im just begining to use the pic18 series

    my current setup is:
    a melabs USB programmer
    PBP 2.45A
    Microcode Studio 2.3.0.0

    my problem is that when i try to do a really basic thing such as make portb.0 go low it doesent work properly

    the following has no effect :
    PORTB.0 = 0

    however this works for some reson:
    low PORTB.4

    thanks in advance for any help and responses

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


    Did you find this post helpful? Yes | No

    Default

    O.K. LOW and HIGH function set the i/o of the PIC as output.

    When you apply the power to the PIC, the POR(Power on Default) value set the i/o as input. You need to set it by writing to the TRISB register (se datasheet for that). Once the i/o is properly set as output you can write it as you did.

    TRISB=0
    PORTB.0=0

    should work. TRISx is placed at the top of your code. You can Even use the OUTPUT directive wich do almost the same thing.

    hth
    Steve

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

  3. #3
    Philip Biebach's Avatar
    Philip Biebach Guest


    Did you find this post helpful? Yes | No

    Thumbs up

    exelent that worked, iv only used the pic16s up until now and was not used to needing Tris, although I was familiar with it.
    I appreciate the quick response mister_e

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


    Did you find this post helpful? Yes | No

    Default

    Well TRISx is needed in all PIC family when you Write directly to the PORT register. You don't need the TRISx setting if you use PBP statement, HSEROUT,SERIN... HIGH, LOW...
    Steve

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

Similar Threads

  1. Need help with I2C syntax problem?
    By Michael Wakileh in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 19th July 2007, 20:11
  2. USART Problem , but don't know where, in pc? or in PIC?
    By precision in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th July 2007, 09:12
  3. Correct syntax please ?
    By malc-c in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 11th June 2006, 10:09
  4. 1 slave 1 master 1 MAX232 1 problem ?
    By SuB-ZeRo in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 31st July 2005, 23:59
  5. Replies: 22
    Last Post: - 12th July 2005, 18:39

Members who have read this thread : 1

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