View Single Post
  #8   Spotlight this post!  
Unread 07-12-2003, 12:42
Rickertsen2 Rickertsen2 is offline
Umm Errr...
None #1139 (Chamblee Gear Grinders)
Team Role: Alumni
 
Join Date: Dec 2002
Rookie Year: 2002
Location: ATL
Posts: 1,421
Rickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant future
Send a message via AIM to Rickertsen2 Send a message via Yahoo to Rickertsen2
Re: EduBot and USART ports

Let me appologize for not posting this when i said i would. This stuff was on my MP3 player, which i lost the cable to and just found.

anyway here ya go:
PHP Code:
/*******************************************************************************
* FILE NAME: sensors.c
*
* DESCRIPTION:
*  Contains routines to read DIRRS+ Sensors
*  
*  Function prototypes etc are in sensors.h
*
*  BY: James Rickertsen
*
*******************************************************************************/

#include <usart.h>
#include <stdlib.h>
#include "printf_lib.h"
#include "ifi_default.h"
#include "ifi_aliases.h"
#include "user_routines.h"
#include "ifi_utilities.h"
#include "sensors.h"

#define SENSOR_SIGNATURE 0b10101010

unsigned char sensors[3];


/* ------------------------ This function reads all three sensors ---------------------- */
void Read_Sensors(void) {
    
unsigned char i;
             
char input_buffer[7];
              
char sensor_buffer[3];
    
char signature_pos;

    
printf("test-1\n");
    for(
1<= 3i++)
    {

        
/*configure buffer to selelct desired sensor*/
        
switch(i)
        {  
            case 
1:
                
rc_dig_out14 0;
                
rc_dig_out15 1;
                
rc_dig_out16 1;
                break;
            case 
2:
                
rc_dig_out14 1;
                
rc_dig_out15 0;
                
rc_dig_out16 1;
                break;    
            case 
3:
                
rc_dig_out14 1;
                
rc_dig_out15 1;
                
rc_dig_out16 0;
                break;
        }
        
//printf("test-2\n");
        
Open2USART(
            
USART_TX_INT_OFF &
            
USART_RX_INT_OFF &
            
USART_ASYNCH_MODE &
            
USART_EIGHT_BIT &
            
USART_CONT_RX &
            
USART_BRGH_LOW129); /*initialize serial connection*/
        //printf("test-3\n");
    
        
gets2USART(input_buffer5);    /*Read in data from sensors*/
        //printf("test-4\n");
            
        // Find the sensor signature in the sensor input (input_str)
        
for (signature_pos=0signature_pos<3signature_pos++) {
            if (
input_buffer[signature_pos] == SENSOR_SIGNATURE) {
                break;
            }
        }
        
        
// Copy the sensor data following the sensor signature into temp_str
        
sensor_buffer[0] = input_buffer[signature_pos+1];
        
sensor_buffer[1] = input_buffer[signature_pos+2];
        
sensor_buffer[2] = '\0';
        
        
/*
        if( input_str[1] == 0b10101010) // Fish the data we are looking for out of the input string
        {
            temp_str[1] = (char) input_str[2];
            temp_str[2] = (char) input_str[3];
        } else if( input_str[2] == 0b10101010)
        {
            temp_str[1] = (char) input_str[3];
            temp_str[2] = (char) input_str[4];
        } else if( input_str[3] == 0b10101010)
        {
            temp_str[1] = (char) input_str[4];
            temp_str[2] = (char) input_str[5];
        }
        */

        //printf("test-6\n");
        
sensors[i] = atoi(sensor_buffer); /*convert ACSII string to int value*/
    
}
    
    
#ifdef DEBUG_MODE
        
printf("L = %d, M = %d, R = %d\n", (int)sensors[1], (int)sensors[2], (int)sensors[3]);
    
#endif
}


/******************************************************************************/
/******************************************************************************/
/******************************************************************************/ 

Quote:
Originally Posted by Dave...
We're trying to use a digital compass (available from Digikey) Honeywell model HMR3100. See the datasheet at: http://www.magneticsensors.com/products.html

The ini_aliases.h header file has the following line:
#define usart2_RX PORTGbits.PORTG2
However, whenever I try to build the project with "usart2_RX" in my user code, I receive the following error:
Executing: "c:\mcc18\bin\mcc18.exe" -p=18F8520 "user_routines.c" -fo="user_routines.o" /i"C:\mcc18\h" -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
C:\EduCode\user_routines.c:328:Error [1205] unknown member 'PORTG2' in '__tag_43'
Does anyone know what "unknown member" or "__tag_43" means and how I can resolve this issue?
I honestly have no idea whats wron with that. Could you post some more code? Rather than set up the USART config registers and write to the TX and RX registers directly, etc, i would use the built in compiler libraries as in the example above. For more info on these functions see:
http://www.microchip.com/download/to...b18/51297b.pdf
there is also 2 really good whitepapers on using the USART in asyncronous mode at the assembly level:
http://www.microchip.com/download/ap...c16/00774a.pdf
http://www.microchip.com/download/li...oots/usart.pdf
__________________
1139 Alumni

Last edited by Rickertsen2 : 07-12-2003 at 14:14.