by clusher » Wed Aug 12, 2009 2:44 pm
by clusher
Wed Aug 12, 2009 2:44 pm
There are a few examples of C programming around, so you should manage with some guidelines.
Basically, you have to do the same that you do with communications with AX-12. Make an interrupt function like:
- Code: Select all
#define RXD1_DATA (UDR1)
unsigned char your_var;
SIGNAL (SIG_UART1_RECV){
your_var =RXD1_DATA;
}
I'm assuming your just trying to save one char. If you need more, then your var should be an array, you need another variable to define the array index you're writing to and do exactly like AX-12 communication:
- Code: Select all
#define RXD1_DATA (UDR1)
unsigned char your_var[128];
unsigned int index=0;
SIGNAL (SIG_UART1_RECV){
your_var[index++] =RXD1_DATA;
}
Don't forget to restart your index variable when you're done reading! Save all the memory you can
EDIT: you also need to enable the Interrupt bit for the PC USART. If you're using the example.c code, you should see
- Code: Select all
cbi(UCSR1B,7); // RxD interrupt disable
You need to change this to sbi(UCSR1B,7).[/code]
There are a few examples of C programming around, so you should manage with some guidelines.
Basically, you have to do the same that you do with communications with AX-12. Make an interrupt function like:
- Code: Select all
#define RXD1_DATA (UDR1)
unsigned char your_var;
SIGNAL (SIG_UART1_RECV){
your_var =RXD1_DATA;
}
I'm assuming your just trying to save one char. If you need more, then your var should be an array, you need another variable to define the array index you're writing to and do exactly like AX-12 communication:
- Code: Select all
#define RXD1_DATA (UDR1)
unsigned char your_var[128];
unsigned int index=0;
SIGNAL (SIG_UART1_RECV){
your_var[index++] =RXD1_DATA;
}
Don't forget to restart your index variable when you're done reading! Save all the memory you can
EDIT: you also need to enable the Interrupt bit for the PC USART. If you're using the example.c code, you should see
- Code: Select all
cbi(UCSR1B,7); // RxD interrupt disable
You need to change this to sbi(UCSR1B,7).[/code]