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(i = 1; i <= 3; i++)
{
/*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_LOW, 129); /*initialize serial connection*/
//printf("test-3\n");
gets2USART(input_buffer, 5); /*Read in data from sensors*/
//printf("test-4\n");
// Find the sensor signature in the sensor input (input_str)
for (signature_pos=0; signature_pos<3; signature_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