Hi,
I'm using robostix-gumstix to control a robo-one
humanoid prototype
I'm having problems to receive character from the
gumstix to the robostix. sending from the robostix to
the gumstix is ok
I'm programming the gumstix using uisp running on the
gumstix. I have done the bridge between the serial
ports as described on the robostix-gumstix-isp
webpage.
I am using wermit -l /dev/ttyS2 on the gumstix side
and the following program on the robostix side.
I would appriciate any hint on what I could be doing
wrong
thanks in advance
Jorge
#include <stdio.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#define F_CPU 16000000
#define mod(x,y) ((x>y)?(x-y):(y-x))
#define BLUE_LED_PIN 3
#define BLUE_LED_MASK ( 1 << BLUE_LED_PIN )
#define BLUE_LED_DDR DDRG
#define BLUE_LED_PORT PORTG
void init_uart0(void)
{
#define UBRR0_INIT 103
UBRR0H = UBRR0_INIT >> 8;
UBRR0L = UBRR0_INIT & 0xFF;
UCSR0A = (0 << U2X0);
UCSR0B = (( 0 << RXCIE0 ) | ( 1 << RXEN0 ) | ( 1 <<
TXEN0 ));
UCSR0C = (( 3 << UCSZ00 ) | ( 0 << UPM01 ) |
( 0 << UPM00 ) | ( 0 << USBS0 ));
}
void init_uart1(void)
{
#define UBRR1_INIT 207
UBRR1H = UBRR1_INIT >> 8;
UBRR1L = UBRR1_INIT & 0xFF;
UCSR1A = (1 << U2X1);
UCSR1B = (( 1 << RXCIE1 ) | ( 1 << RXEN1 ) | ( 1 <<
TXEN1 ));
UCSR1C = (( 3 << UCSZ10 ) | ( 0 << UPM11 ) |
( 0 << UPM10 ) | ( 0 << USBS1 ));
}
void pausa_16ms(void)
{
TCNT0 = 0;
TCCR0 = _BV(WGM01) | _BV(CS02) | _BV(CS01) |
_BV(CS00); // timer 0 modo CTC, sin salida y con 1/64
OCR0 = 255;
loop_until_bit_is_set(TIFR, OCF0); // espero 868 us
hasta el primer valor a leer
TIFR |= _BV(OCF0); // bajo el flag escribiendo un 1
}
unsigned char USART0_Receive( void )
{
/* Wait for data to be received */
while ( !(UCSR0A & (1<<RXC)) )
;
/* Get and return received data from buffer */
return UDR0;
}
#define PORT_AMARILLO PORTB
#define PORT_ROJO PORTG
#define PORT_AZUL PORTG
#define LED_AMARILLO PB4
#define LED_ROJO PG4
#define LED_AZUL PG3
int main(void)
{
uint8_t j;
init_uart0();
init_uart1();
DDRG = _BV(DDG4) | _BV(DDG3); //roja y azul
DDRB = _BV(DDB4);//amarilla
DDRE = _BV(DDE1);
sei(); // habilito interrupciones
while(1)
{
PORTG=! (_BV(LED_ROJO) |
_BV(LED_AZUL));
// if ( uart0_getchar(0) == 'c' )
if ( USART0_Receive() == 'c' )
{
PORTB=!_BV(LED_AMARILLO);
}
else
{
PORTB=_BV(LED_AMARILLO);
}
for(j=1;j<30;++j) pausa_16ms();
PORT_ROJO=_BV(LED_ROJO);
// PORTB=_BV(LED_AMARILLO);
for(j=1;j<30;++j) pausa_16ms();
//BLUE_LED_PORT=BLUE_LED_MASK;
}
return 0;
}
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
|