Society of Robots - Robot Forum
Electronics => Electronics => Topic started by: NERO on December 11, 2007, 10:03:15 AM
-
hi...
i have bought cmu camera version 1....
i have a problem to interface with my microcontroller....
i have read the manual.....and use the ttl communication types....
but nothing happen.... i am trying to give command "L1 1" to make the tracking led on.
should i need any converter?
-
can you paste the code you are using on the PIC
-
tell us more about your hardware setup, too
-
Did you send the newline character?
-
This is my code.... i use TTL channel from CMU cam board...
My connection Rx Cmu -->Tx PIC(RC6) and Tx Cmu -->Rx PIC(RC7)
#include <system.h>
//Target PIC16F877 configuration word
#pragma DATA _CONFIG, _PWRTE_OFF & _BODEN_OFF & _WDT_OFF & _LVP_ON & _CPD_OFF & _DEBUG_OFF & _HS_OSC & _CP_OFF
//Set clock frequency
#pragma CLOCK_FREQ 20000000
void serial_init(void)
{
trisc = 10000000b;
set_bit( rcsta, SPEN ); // Enable Serial port
spbrg = 129; //set baudrate 9600bps
set_bit( txsta, BRGH ); // RRGH = 1 ( High speed mode )
set_bit( txsta, TXEN ); // Enable Transmitter
set_bit( pie1, RCIE ); // Enable Receive Interrupt
set_bit( pie1, TXIE );
set_bit( rcsta, CREN ); // Enable continuous receive
set_bit( intcon, PEIE ); // Enable all Peripheral Interrupts
set_bit( intcon, GIE ); // Enable Global Interrupts
}
void serialSendChar(char value)
{
while((txsta & 1 << TRMT) == 0); // TRMT is better then TXIF
txreg = value;
clear_bit(pie1,TXIE);
}
char serialReceiveChar()
{
while((pir1 & 1 << RCIF) == 0);
return rcreg;
}
void serialSendString(const char* text)
{
char i = 0;
while(text != 0)
serialSendChar(text[i++]);
}
void interrupt( void )
{
//Handle port change interrupt
if( intcon & (1<<RBIF) )
{
clear_bit( intcon, RBIF );
}
//Handle external interrupt
if( intcon & (1<<INTF) )
{
clear_bit( intcon, INTF );
}
//Handle timer0 interrupt
if( intcon & (1<<T0IF) )
{
clear_bit( intcon, T0IF ); //clear timer 0 interrupt bit
}
}
void main( void )
{
serial_init();
delay_s(2);
serialSendString("RS\r");
delay_s(5);
//Endless loop
do{
serialSendString("L1 1\r");
delay_s(2);
serialSendString("L1 0\r");
delay_s(2);}
while( 1 );
}
-
the datasheet for the cmu cam 1 says that the baud rate should be 115,200 baud. You currently have it set at 9,600 on the PIC.
There is no SPBRG value available on the PICs datasheet for that fast baud rate, though you could try using 10 as the SPBRG value and you might get somewhere, otherwise youll need to get a different mcu.
If 10 doesnt work try setting at 0 and working up to 10, you might get lucky and hit on a magic number.
-
apparently theres a jumper on the cmu board to reduce the baud down to 38,400 but you would need to fiddle with the spbrg value since there doesnt appear to be one in the pic datasheet
-
hi...
but i have tested with baudrate 115200....
it still give the same condition.....
so i decided to try 9600bps coz ttl has a limit speed...
am i right?