12f675_fuse_about_to_blow!


Closed Thread
Results 1 to 40 of 929

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    it works up to DEC255 then ouputs a zero for 256 etc, which is larger than a BYTE I'm thinking.
    Yup, remember when counting not to start at 1 like we were taught in school.
    Always start at the origin... ZERO

    Hmm, a little stumped here. To my mind (after a lot of reading but obviously not enough!) when the first BYTE (number) arrives I need to send it to a memory location where it won't be overwritten when the second BYTE arrives.Then add the two together.

    The only thing I've found so far that has a seperate address element is this (I think):
    I was thinking along the lines of something like this for now
    Code:
    NUM1  VAR  BYTE
    NUM2  VAR  BYTE
    I was saving ARRAYs for a little latter
    I'm thinking: MYVAR VAR BYTE [1] which is two elements 0,1. then somehow add element 0 to element1.
    But if you want to read ahead...
    http://www.picbasic.co.uk/forum/showthread.php?t=544
    Dave
    Always wear safety glasses while programming.

  2. #2
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default

    Hi mackrackit

    But if you want to read ahead...
    I'm with you, reading ahead is ok but learn to walk then run (or crawl then walk in my case).

    Just out of interest would the ARRAY idea have worked?

    This code is just an idea, is it on the right lines?

    Code:
    SERIN2 PORTC.5, 16780, [DEC NUM1] 'MODE 16780 = 2400 BAUD INVERTED
    
    SERIN2 PORTC.5, 16780, [DEC NUM2] 'MODE 16780 = 2400 BAUD INVERTED
    
    LET TOTAL = NUM1 + NUM2
    
    SEROUT2 PORTC.3 TOTAL

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    An array can be made to work and so could your code as it is written, but...

    One of the things you need to consider is, how is the data coming into the MCU?
    123
    1,2,3
    12,3
    12M3
    ...........
    The code on the MCU needs to know what to expect or it is not going to know what to do with the data.
    That is where arrays come in handy, but then you need to figure out what and where the data you want to use is located in the array.

    I know, not a direct answer
    Reread the section of the manual SERIN2 and the WAIT thing. Also find out what DEC2 or DEC3 does.
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default

    I've been trying to use WAIT. I put in ( 2 ) hoping it would let me enter two numbers but it wouldn't compile (syntax error)

    Code:
     WAIT ( ) Wait for sequence of characters
    Reread the section of the manual SERIN2 and the WAIT thing. Also find out what DEC2 or DEC3 does.
    Will do, tomorrows task

  5. #5
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default

    Hi mackrackit,

    How does this look? It works but is it what you were after?

    Code:
    ANSEL   = %00000000    'Disable analog select so ports work as digital i/o.
    CMCON0  = %00000111    'Disable analog comparators.
    TRISA   = %00000000    'Set PORTA as OUTPUT.
    PORTA   = %00000000    'Set PORTA pins all low.
    TRISC   = %00000000    'Set PORTC as OUTPUT.
    PORTC   = %00000000    'Set PORTC pins all low.
    
    DEFINE OSC 4
    
    NUM1 VAR BYTE
    
    NUM2 VAR BYTE 
    
    TOTAL VAR BYTE
    
    i var byte
     
    MAIN:
    PAUSE 250
    
    SERIN2 PORTC.5, 16780,[WAIT ("N1="), DEC NUM1]  'MODE 16780 = 2400 BAUD INVERTED
    PAUSE 2000
    HIGH PORTA.5
    PAUSE 2000
    LOW PORTA.5
    SERIN2 PORTC.5, 16780,[WAIT ("N2="), DEC NUM2]
    
    HIGH PORTA.5
    LET TOTAL = NUM1 + NUM2
    PAUSE 2000
    low PORTA.5
    pause 250
    SEROUT2 PORTC.3, 16780, [DEC TOTAL, 10, 13] 'OUTPUT IN DEC 'TOTAL' 10=L_FEED 13=C_RETURN
    pause 2000
    GOTO MAIN
    Dave

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by LEDave View Post
    How does this look? It works but is it what you were after?
    COOL!!!
    I was not really after anything exactly, just trying to give you enough information to figure it out and you did!!!

    Now try sending sending 123 with out N1= or N2=.
    Code:
    SERIN2 PORTC.5, 16780,[DEC NUM1, DEC NUM2]
    Then try
    Code:
    SERIN2 PORTC.5, 16780,[DEC2 NUM1, DEC NUM2]
    Then try
    Code:
    SERIN2 PORTC.5, 16780,[DEC NUM1, DEC2 NUM2]
    Then try
    Something else....
    You will also want to look at the TIME OUT option of SERIN2.
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default

    Code:
     [WAIT ("N1=")
    This took me ages to figure out But hey, got there in the end

    I've also had a little play with DEC, DEC1.... late last night.

    From what I've found, I think I'm right in saying 'DEC' is good up to 255 NUM1 VAR BYTE, send 256 and it returns a '0'.

    'DEC1' is good 0 - 9 if you sent '23' then you'd only get a '2'

    'DEC4' If you'd sent '99' you'd get '0099', '255' would give '0255' & 256 would return '0000'........ETC.

    I'll have a look at the combinations you've posted this evening.

    I know progress is slow but we're making progress

    See you later.

    Dave

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