modtronix.com
September 02, 2010, 06:24:34 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: SMF - Just Installed
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: == IOR5E Test code ==  (Read 5582 times)
Administrator
Hero Member
*****
Posts: 171


View Profile WWW
« on: August 29, 2005, 10:37:37 PM »

Below is some sample code for testing all LEDs and relays on the IOR5E. Simply add this code to your mxwebsrvr.c file of the SBC65EC source code download. This code will sequentially turn all LEDs and Relays on and off.

Code:
//Latch pins
#define LATCH_SER       PORTC_RC0
#define LATCH_SCLK      PORTC_RC1
#define LATCH_RCLK      PORTC_RC2
#define LATCH_OE        PORTC_RC5
#define TRIS_LATCH_SER  TRISC_RC0
#define TRIS_LATCH_SCLK TRISC_RC1
#define TRIS_LATCH_RCLK TRISC_RC2
#define TRIS_LATCH_OE   TRISC_RC5

/**
* Write the given value to the 595s internal register. It is not latched to it's output register.
* Important!! After calling this function, the output register must still be latched:
*
*   //Latch the 595's internal register to it's output register
*   LATCH_RCLK = 1;
*   LATCH_RCLK = 0;
*
*/
void setLatch595(BYTE c) {
    BYTE mask = 0x80;

    LATCH_RCLK = 0;
   
    //Shift all 8 bits into latch
    for (;;) {
        //Shift out next bit
        LATCH_SCLK = 0;
        if (c & mask)
            LATCH_SER = 1;
        else
            LATCH_SER = 0;
        LATCH_SCLK = 1;

        //Break if all 8 bits have been shifted out
        if (mask == 0x01) break;
        mask = mask >> 1;
    }
    LATCH_SCLK = 0;
}

/*
* Main entry point.
*/
void main(void)
{
    BYTE latchRly, latchLED1, latchLED2;
    .....

    //Reset all outputs to 0
    TRIS_LATCH_SER  = 0;
    TRIS_LATCH_SCLK = 0;
    TRIS_LATCH_RCLK = 0;
    setLatch595(0);
    setLatch595(0);
    setLatch595(0);
    //Clock 595's internal register
    LATCH_RCLK = 1;
    LATCH_RCLK = 0;

    //Now (after all output have been initialized with 0, Enable output latches
    TRIS_LATCH_OE = 0;
    LATCH_OE = 0;

    //Initialize Relay and Latch outputs
    latchRly = 0x01;
    latchLED1 = 0x01;
    latchLED2 = 0x01;

    while(1)
    {
        ........

        /*
         * Increment Relay, LED latches every 500ms
         */
        if ( TickGetDiff(TickGet(), tTest) >= TICK_SECOND/4 )
        {
            tTest = TickGet();
           
            //Rotate values by one
            latchRly <<= 1;
            latchLED1 <<= 1;
            latchLED2 <<= 1;
            if (latchRly == 0) {
                latchRly = 0x01;
                latchLED1 = 0x01;
                latchLED2 = 0x01;
            }

            //Shift out all latches
            setLatch595(latchLED2);
            setLatch595(latchLED1);
            setLatch595(latchRly);

            //Clock 595's internal register
            LATCH_RCLK = 1;
            LATCH_RCLK = 0;
        }

        ...........
    }

    .........
}
« Last Edit: June 22, 2007, 02:07:44 PM by modtro2 » Logged

*** Modtronix Engineering Support ***
marceloq
Newbie
*
Posts: 1


View Profile Email
« Reply #1 on: August 06, 2006, 04:25:00 PM »

hi this code i have function whith SBC68EC ?
I add this code in mxwebsrvr.c file of the SBC68EC source code download and not compiling god.

Executing: "C:\MCC18\bin\mcc18.exe" -p=18F6680  /i"C:\MCC18\h" /i"C:\Desarrollo\WebServer\src" "mxwebsrvr.c" -fo="tmp\mxwebsrvr.o" -sco -DBRD_SBC68EC -DHAS_BOOTLOADER -Ls -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
MPLAB C18 v3.02 (demo)
Copyright 1999-2005 Microchip Technology Inc.
Days remaining until demo becomes feature limited:  50
C:\Desarrollo\WebServer\src\mxwebsrvr.c:130:Warning [2074] location .tmpdata specified in the interrupt save list is redundant
C:\Desarrollo\WebServer\src\mxwebsrvr.c:461:Error [1504] redefinition of 'main'
C:\Desarrollo\WebServer\src\mxwebsrvr.c:491:Error [1105] symbol 'tTest' has not been defined
C:\Desarrollo\WebServer\src\mxwebsrvr.c:493:Error [1105] symbol 'tTest' has not been defined
C:\Desarrollo\WebServer\src\mxwebsrvr.c:493:Error [1101] lvalue required
Logged
Marco_Beulke
Jr. Member
**
Posts: 8


View Profile
« Reply #2 on: June 28, 2009, 01:48:04 PM »

 huh
Hello I have an SBC65 with V3.10 on it. and I wantes to buld in your testcode but I got the same error.
C:\Users\Marco\Desktop\sbc\firmware\websrvr65_v310\src\mxwebsrvr.c:470:Error [1105] symbol 'tTest' has not been defined
C:\Users\Marco\Desktop\sbc\firmware\websrvr65_v310\src\mxwebsrvr.c:472:Error [1105] symbol 'tTest' has not been defined
C:\Users\Marco\Desktop\sbc\firmware\websrvr65_v310\src\mxwebsrvr.c:472:Error [1101] lvalue required
 may anyone can help me.
maybe I donīt understand anything wrong in the code:
 
while(1)
    {
       
         .......... (I dont know what i have to do here)
        /*
         * Increment Relay, LED latches every 500ms
         */
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!