[SOLVED !] Need a little help in assembler, please...


Closed Thread
Results 1 to 9 of 9

Thread: Need a little help in assembler, please...5116 days old

  1. #1
    pdgnr
    Guest pdgnr's Avatar

    0 Not allowed!

    Default Need a little help in assembler, please...

    Good day all,

    I have a small routine in Proton that I should be please to translate in assembler, as it is an interrupt handler.
    Unfortunatly, I don't know anything in assembler...

    Here is the actual routine where encod, old_encod and flagint are declared previously as byte. Tampon is an array of 13 bytes.

    DelayMs 5
    encod = PORTB
    if encod.4 = 0 then
    if old_encod.4 = 1 then
    if encod.0 = 0 then
    StrN Tampon = "1&1234567890"
    Else
    StrN Tampon = "1&0987654321"
    EndIf
    Flagint = 1
    EndIf
    EndIf
    old_encod = encod
    Clear INTCON.0
    Resume

    Can anybody help me and translate it in an hardware interrupt handler ?

    Thanks by advance,

    Robert

  2. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #2
    Fanatical Contributor Tim's Avatar
    Join Date
    Jan 2003
    Posts
    7,754
    Thumbs Up
    Received: 51
    Given: 96
    Total Downloaded
    1.33 GB

    0 Not allowed!

    Default

    Robert Why do you need to conver it to ASM?

    Apart from the delay which is not a good idea in an interrupt routine it can be written as it is.
    Tim

  4. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #3
    pdgnr
    Guest pdgnr's Avatar

    0 Not allowed!

    Default

    Hi Tim,
    thanks for your help... From your answer, I deduce that I had a wrong idea about interrupts. Due to my english -very light - I believed that an hardware handler would be written in ASM. Of course, I prefer to use Proton!
    As far as the delay is concerned, I agree with your remark, however I did not find an other way to debouce the rotary encoder (that the routine decode...)

    Best regards,

    Robert

  6. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  7. #4
    Fanatical Contributor Tim's Avatar
    Join Date
    Jan 2003
    Posts
    7,754
    Thumbs Up
    Received: 51
    Given: 96
    Total Downloaded
    1.33 GB

    0 Not allowed!

    Default

    Robert

    I'm always impressed when soem one can speak more than one language! I can barely speek 1!

    Thats the great thing about Proton most stuff most code in an interrupt routine can be written in basic. If you have any worries about it then use BISVS to check it over for you.

    Re de-bouncing its difficult but not impossible. You have to see it set for a length of time before you take it as de-bounced. Basically you have to have 2 things going.

    1 an interrupt routine to see the pulse. 2 when you see it you then start a timer (hardware) and you ignore all other pulses until the value in the timer is past a certain value.

    It involves a little more than that but its on the right lines.

    I want to write a switch style rotary encoder routine to use in user inputs when I have it done I will let you have the code.
    Tim

  8. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  9. #5
    pdgnr
    Guest pdgnr's Avatar

    0 Not allowed!

    Default

    Hi Tim,
    that would be a great help if this routine was available soon... I have much difficulties to get a correct behaviour of my encoder, as this routine is embedded in a program wich talks to a PC via USB. I use easyHid, and the USB routines are for me a "black box". Perhaps timers are yet used inside ?
    Another example: if I send the buffer named Tampon from inside the interrupt, the Pic crash. If I send the packet outside the interrupt, that works. With the pic 18f4550, interrupts are not very easy to master, specially for non english readers of the data sheet ...

    Thanks once more,

    Robert

  10. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  11. #6
    Fanatical Contributor Tim's Avatar
    Join Date
    Jan 2003
    Posts
    7,754
    Thumbs Up
    Received: 51
    Given: 96
    Total Downloaded
    1.33 GB

    0 Not allowed!

    Default

    Here is what I wrote, its not tested but will compile. The idea is correct but might need a little Tweek!

    Code:
        Device 18F4550
        
        Symbol RBIF = INTCON.0   ' RB Port Interrupt Flag
        Symbol INT0IF = INTCON.1 ' INT0 External Interrupt Flag
        Symbol TMR0IF = INTCON.2 ' TMR0 Overflow Interrupt Flag
        Symbol RBIE = INTCON.3   ' RB Port Change Interrupt Enable
        Symbol INT0IE = INTCON.4 ' INT0 External Interrupt Enable
        Symbol TMR0IE = INTCON.5 ' TMR0 Overflow Interrupt Enable
        Symbol PEIE = INTCON.6   ' Peripheral Interrupt Enable
        Symbol GIEL = INTCON.6   ' Peripheral Interrupt Enable
        Symbol GIE = INTCON.7    ' Global Interrupt Enable
        Symbol GIEH = INTCON.7   ' Global Interrupt Enable
        
        Symbol T0PS0 = T0CON.0  ' Timer0 Prescaler Select bit
        Symbol T0PS1 = T0CON.1  ' Timer0 Prescaler Select bit
        Symbol T0PS2 = T0CON.2  ' Timer0 Prescaler Select bit
        Symbol PSA = T0CON.3    ' Timer0 Prescaler Assignment bit
        Symbol T0SE = T0CON.4   ' Timer0 Source Edge Select bit
        Symbol T0CS = T0CON.5   ' Timer0 Clock Source Select bit
        Symbol T08BIT = T0CON.6 ' Timer0 8-bit/16-bit Control bit
        Symbol TMR0ON = T0CON.7 ' Timer0 On/Off Control bit
    
    
        
        Dim encod As Byte
        Dim old_encod As Byte
        Dim Tampon[13] As Byte
        Dim flagint As Bit
        
        Dim DebounceTime As 187                                 ; Approx 5 ms with a 1:128 prescaler and running at 48mhz
    
        
    Initialise:
        T08BIT = 1                                              ; were using it in 8 bit mode
        T0CS  = 0                                               ; Clocking off the OSC
        PSA = 0                                                 ; Using the prescaler
        T0PS2 = 1                                               ; Set up our precaler to 1:128
        T0PS1 = 0
        T0PS0 = 0
        TMR0ON = 1                                              ; Set it running
        TMR0L = 0                                               ; and clear it all
         
        
        If TMR0IF = 1 Then GoTo ReadNow                         ; If the timer has rolled over then were well debounced
        If TMR0L > DebounceTime Then                            ; If were over out debounce time
    ReadNow:
            encod = PORTB
            If encod.4 = 0 Then           
                If old_encod.4 = 1 Then            
                    If encod.0 = 0 Then
                        StrN Tampon = "1&1234567890"
                        Else
                        StrN Tampon = "1&0987654321"
                    EndIf
                    TMR0L = 0                               ; clear the 
                    TMR0IF = 0
                    flagint = 1
                EndIf
            EndIf
        EndIf
        old_encod = encod
        Clear INTCON.0
    Tim

  12. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  13. #7
    mikedownunder
    Guest mikedownunder's Avatar

    0 Not allowed!

    Default

    Tim

    Is this for one of those rotary encoders that send out a pulse for clockwise and anti-clockwise rotation.

    I hope so, cause I have been trying to do this on and off for ages, and I know you're the 'Interrupt man'.

    Thanks

    Mike

  14. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  15. #8
    pdgnr
    Guest pdgnr's Avatar

    0 Not allowed!

    Default

    Hi Tim,
    very kind of you to take some times on this problem...
    I will try your code as soon as possible ans let you know the result.

    With best regards,

    Robert

  16. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  17. #9
    pdgnr
    Guest pdgnr's Avatar

    0 Not allowed!

    Default

    Hi Tim, I tried your code as "stand-alone". It works, but now it is my routine for decode the sense of rotation wich fails, or perhaps I did not understand very well how to use your code.
    The idea, I suppose is:

    The change of portB raise an interrupt. We go to the handler, set the params for the timer and return to the program untill the timer overflow and raise itself an interrupt. Then, come back to the handler, check that the interrupt is due to the timer and if so, proceed to decode.
    If I have well understood the idea, I have three questions :

    - why TMR0L is not loaded with the difference between 255 and DebounceTime for overflow,
    - why the test of TMR0IF is done after Initialise (and not before to check who has raised the interrupt),
    - at what moment can we check that TMR0L > DebounceTime, as the next time after Initialise when we will be back in the handler will be when TMR0L overflow ?

    All right... don't laugh too much if these questions are stupid... I have a few difficulties to decode the english of the datasheet, and some parameters stay in the dark for me...

    Fortunatly, you are here...

    Best regards,

    Robert

  18. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Assembler to Proton
    By teo in forum Proton Plus Compiler v3
    Replies: 9
    Last Post: 23rd August 2018, 13:47
  2. Assembler listing
    By towlerg in forum Proton Plus Compiler v3
    Replies: 1
    Last Post: 22nd February 2017, 16:57
  3. Microchip assembler
    By towlerg in forum The Lounge
    Replies: 2
    Last Post: 19th October 2016, 19:27
  4. [SOLVED !] Assembler
    By nullsoft in forum The Lounge
    Replies: 21
    Last Post: 11th February 2010, 09:02
  5. Help in assembler
    By pdgnr in forum Proton Plus Compiler v3
    Replies: 3
    Last Post: 28th March 2006, 10:02

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts