• #2 - Amicus18 and Pic Basic Pro... A start.

    From this article http://www.picbasic.co.uk/forum/cont...ro-Code-Studio

    you learned how to setup the Amicus18 bootloader to work with Micro Code Studio. Now we will look

    at the sample programs from the Amicus18 Hardware Manual that can be found here,

    http://www.myamicus.co.uk/content.php?117-Documents

    When using the Amicus18 bootloader the configuration file, 18F25K20.inc, from the PBP directory is

    not used. The "configs" are set in the bootloader. By default the 18F25K20 will run at 64MHz.

    The first code is a simple "blinky"
    Code:
    ' PIC18F25K20 ON THE AMICUS BOARD
    ' FLASH AN LED CONNECTED TO PORTB.0
    
        DEFINE OSC 64         'THE 16MHz IS PLL'ed TO 64 MHz
        DEFINE LOADER_USED 1  'USING THE AMICUS USB BOOT-LOADER
        ANSEL = 0             'ALL ANALOG TO DIGITAL
        ANSELH = 0  
        PORTB = 0             'MAKES PORTB LOW
        TRISB=%00000000       'MAKES PORTB PINS OUTPUTS
        LED VAR PORTB.0       'NAMES PORTB.0 "LED"
        
        While 1 = 1           'CREATES AN INFINATE LOOP     
            High LED              'PORTB.0 HIGH
            PAUSE 500             '1/2 SECOND PAUSE 
            Low LED               'PORTB.0 LOW
            PAUSE 500   
        Wend
    The next program is another "blinky" showing how to use both of the PWM hardware ports on the

    18F25K20.
    Code:
    ' PIC18F25K20 ON THE AMICUS BOARD
    ' PULSE TWO LEDs, ONE INCREASES IN BRIGHTNESS AS THE OTHER DECREASES
    
        DEFINE OSC 64         'THE 16MHz IS PLL'ed TO 64 MHz
        DEFINE LOADER_USED 1  'USING THE AMICUS USB BOOT-LOADER
        ANSEL = 0             'ALL ANALOG TO DIGITAL
        ANSELH = 0  
        DUTY_CYCLE  VAR WORD  'DUTY CYCLE VARIABLE
        
        WHILE 1 = 1
        FOR DUTY_CYCLE = 0 TO 1023  'COUNTS FROM 0 TO 1023
            HPWM 1,DUTY_CYCLE,1000  'OUTPUTS ON PORTC.2
            HPWM 2,1023-DUTY_CYCLE,1000   'OUTPUTS ON PORTC.1
            PAUSE 5
        NEXT
        PAUSE 5
        FOR DUTY_CYCLE = 1023 TO 0 STEP -1
            HPWM 1,DUTY_CYCLE,1000
            HPWM 2,1023-DUTY_CYCLE,1000
            PAUSE 5
        NEXT
        PAUSE 5
        WEND