View Single Post
  #22   Spotlight this post!  
Unread 29-09-2006, 23:18
Chermaine Chermaine is offline
Registered User
no team
 
Join Date: Jul 2006
Location: Malaysia
Posts: 2
Chermaine is an unknown quantity at this point
Re: SONAR Sensor Software Driver

I have managed to solve the previous post questions.

At present,

I have modify the software code for my project application. I am using a PIC18F452 microcontroller for the ping sensor. Everything works fine until programming the USART code. The hyper terminal characters does not change when the distance of the object changes.

Can you help me? I have a very close deadline to meet.

Follow is the code i added prior to Mike's codes:



#include <p18f452.h> // version 1.1
#include <usart.h>
#include "sonar.h"
/* Set configuration bits
* - set HS oscillator
* - disable watchdog timer
* - disable low voltage programming
*/

#pragma romdata CONFIG
_CONFIG_DECL(_CONFIG1H_DEFAULT & _OSC_HS_1H,
_CONFIG2L_DEFAULT,
_CONFIG2H_DEFAULT & _WDT_OFF_2H,
_CONFIG3H_DEFAULT,
_CONFIG4L_DEFAULT & _LVP_OFF_4L,
_CONFIG5L_DEFAULT,
_CONFIG5H_DEFAULT,
_CONFIG6L_DEFAULT,
_CONFIG6H_DEFAULT,
_CONFIG7L_DEFAULT,
_CONFIG7H_DEFAULT);
#pragma romdata

int i;
int distance;

void main(void)
{
int i=0;

Initialize_Sonar();
Ping_Sonar();
Hardware_Interrupt_Sonar();
Timer_Interrupt_Sonar();
Get_Sonar_Distance();

OpenUSART (USART_TX_INT_OFF &
USART_RX_INT_ON &
USART_ASYNCH_MODE &
USART_EIGHT_BIT &
USART_CONT_RX &
USART_BRGH_HIGH, 129); // open USART with baud of 9600

while(i<10)
{
putrsUSART("A");
putrsUSART(distance);
putrsUSART("B");
i++;
}
}