Counting led blinks..


Closed Thread
Results 1 to 40 of 93

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 Re: Counting led blinks..

    Does the Loop2 part still work in the code with the usbtx sub routine? It looks to me like it should work. Or maybe it is too long between USBservices.

    If that is the case include the routine to service the USB in the background like the example gave for testing.
    Dave
    Always wear safety glasses while programming.

  2. #2
    Join Date
    Jun 2011
    Location
    Philippines
    Posts
    223


    Did you find this post helpful? Yes | No

    Default Re: Counting led blinks..

    Hi, yes Loop2 still works(i increments), but I wonder why usbtx does not sends the "c" character to pc?

    regards,
    tacbanon

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


    Did you find this post helpful? Yes | No

    Default Re: Counting led blinks..

    Give this a shot. It works here.

    Code:
    INCLUDE "cdc_desc.bas"
    INCLUDE "USB_ASM_Service.pbp"    ' Base Interrupt System
    
    
    LED       VAR PORTB.0
    Buffer    VAR BYTE[10]
    Buffer2    VAR BYTE[10]
    Cnt       VAR BYTE
    
    
    i    var byte
    ADCON1 = 15               ' Set all I/Os to Digital      
    CMCON = 7                 ' Disable Comparators
    Cnt = 5
    i = 0
    '****************************************************
    TRISA.4 = 1 ' RA4/T0CKI = input to TMR0 counter
    'If you prefer, then increment on low-to-high transitions
    T0CON   = 111000        
    LOW LED
    Loop1:
    TMR0L = 0     ' Clear TMR0 count before start   
    '**************ADDED COde
    gosub usbtx   ' transmit character c to pc
    '**************************** 
    Loop2:
    WHILE TMR0L = 0 ' Wait for high-to-low transition      
    WEND           ' on RA4/T0CKI
    pause 5
    PORTA.2 = 1    ' LED on to indicate transition seen     LED PORTA.2 
    i=i+1       ' Clear screen
    buffer[0] = 49
    Buffer[1] = 13       
    USBOut 3, Buffer, 2,Loop2
    LOW LED   ' LED off
    goto Loop1   
    
    
    usbtx:
    TOGGLE LED
    Buffer2[0] = 99
    Buffer2[1] = 13       
    USBOut 3, Buffer2,2,usbtx
    return
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Jun 2011
    Location
    Philippines
    Posts
    223


    Did you find this post helpful? Yes | No

    Default Re: Counting led blinks..

    Hi, thanks for the time. I run your code...but the character "c" appears only when a pulse is detected in my setup. Hmm it should be running as expected...

    regards,
    tacbanon
    Attached Images Attached Images  

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


    Did you find this post helpful? Yes | No

    Default Re: Counting led blinks..

    That is what I thought you wanted?

    If you want it to send "C" continuously
    Code:
    WHILE TMR0L = 0 ' Wait for high-to-low transition  
      GOSUB usbtx  
      PAUSE 100 
    WEND           ' on RA4/T0CKI
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Jun 2011
    Location
    Philippines
    Posts
    223


    Did you find this post helpful? Yes | No

    Default Re: Counting led blinks..

    Hi, sorry if was not making clear..it's working now. acctually the reason I need to send "c" is to identify if the usb device is connected to the my pc application. My next step is to incorporate rtc and sdcards for record keeping. I will post my code later... thanks mackrackit.

    regards,
    tacbanon

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


    Did you find this post helpful? Yes | No

    Default Re: Counting led blinks..

    glad I could help.
    Dave
    Always wear safety glasses while programming.

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