PIC 18F46K22 Wierdness


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Default Re: PIC 18F46K22 Wierdness

    I believe it's basically the same issue as Ioannis had the other day when he tried to use HIGH/LOW on anything but a PORT register.

    Any command that automatically makes the pin in question and input or output (ie clears or sets the TRIS registers for you) must to use PORTx.y
    This is because the compiler uses a hardcoded "offset" to get from the PORT register to the TRIS register.

    On the 18F46K22 this "offset" between any of the PORT registers and their corresponding TRIS registers is 18 so if, for example, you use LATA.0 instead of PORTA.0 as your SHIFTOUT pin the result will be that the compiler clears OSCTUNE.0 instead of TRISA.0.

    /Henrik.

  2. #2
    Join Date
    Feb 2003
    Posts
    432


    Did you find this post helpful? Yes | No

    Default Re: PIC 18F46K22 Wierdness

    Many thanks to Richard and Dave for letting me know I should be using PORT instead of LAT and thanks to Henrik for the explanation.

    Making the changes has fixed the issue and also cured a couple of other bits of randomness that were also happening.

    Upto this point the program has basically been proof of concept hence why various subroutines we prototyped on another PIC before being inserted into the main code. Time now to do an upto date printout and get the highlighter pens out to note all the changes I need to make to get my program tidied up and working the way I want it to.

    Thanks again guys.
    Keith

    www.diyha.co.uk
    www.kat5.tv

Similar Threads

  1. 18F46K22 HPWM blips and errors
    By comwarrior in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 30th May 2013, 01:23
  2. 18F46K22 being dyslexic
    By comwarrior in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 7th August 2012, 19:00
  3. SDFS on 18F46K22
    By comwarrior in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 14th July 2012, 16:27
  4. Possible PicBasic Pro ADC bug with 18F46k22
    By JimAvanti in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 23rd February 2012, 20:20
  5. Timer1 and Interupt wierdness
    By mind in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 23rd August 2005, 01:24

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