Buy an Axon, Axon II, or Axon Mote and build a great robot, while helping to support SoR.
0 Members and 1 Guest are viewing this topic.
int main(){ int recieved_num=0,i; //Variables DDRD &= ~0x01; //Set RX for input (Do I have to do this?) //DDRD &= ~0x04; //I tried doing synchronous... still no luck this was for clock in //DDRD |= 0x02; //Set TX for output (used it for loop back test) UCSRC = 0x06; //Asynchronous, no parity, 1 stop bit, 8-bit char size UBRRH = 0x00; //First part of baud rate... need value of 12 or 0x00C UBRRL = 0x0C; //Second part of baud rate UCSRB = 0x10; //Enable Reciever display(888,500); //Just a test display, lets me know it's on for(;;) //Infinite loop { while(!(UCSRA & 0x80)); //While recieve flag is not set... recieved_num = UDR; //Get data in UDR display(recieved_num,50); //Dispaly data }}
int main(){ int i=0; DDRD = 0x06; //Set TX for output (and blinker LED) UBRRH = 0x00; //First part of baud rate (4 most sig. digits), need 12 or 0x00C UBRRL = 0x0C; //Second part of baud rate (8 least sig. digits) UBRRH = 0x80; //Set bit so I can access UCSRC UCSRC |= 0x06; //Asynchronous, No parity, 1 stop bit, 8-bit char size UCSRB = 0x08; //Enable Transmitter pause(8000); //Pause to let the recieving chip come online for(;;) //Infinite Loop { for(i=1;i<255;i++) //Wasn't sure how high of a number I could transmit.. { while(!(UCSRA & 0x20)); //While data register is not empty... UDR = i; //Put i into UDR pause(2000); //Pause to let other MCU display number } }}
‚ƒ€‚ƒ„…†‡„…†‡ˆ‰Š‹ˆ‰Š‹ŒŽŒŽ‘’“‘ ’“”•–—”•–—˜™š›˜™š›œžŸœžŸ ¡¢£ ¡¢£¤¥¦§¤¥¦§¨©ª«¨©ª«¬ ®¯¬ ®¯°±²³°±²³´µ¶·´µ¶·¸¹º»¸¹ º»¼½¾¿¼½¾¿ÀÁÂÃÀÁÂÃÄÅÆÇÄÅÆÇÈÉÊËÈÉÊËÌÍÎÏÌÍÎÏÐÑÒÓÐÑÒÓÔÕÖ×ÔÕÖ×ØÙÚÛØÙÚÛÜÝÞßÜÝÞßàáâãàáâãäåæçäåæçèéêëèéêëìíîïìíîïðñòóðñòóôõö÷ôõö÷øùúûøùúûüýþ üýþ
#include <avr/io.h>#include "C:\\ReaperR.h"int main(){ PORT_OFF(DDRD,DDD0); //Make sure Rx is input PORT_OFF(UCSRA,U2X); //Make sure double speed isn't activated PORT_OFF(UCSRA,MPCM); //Make sure multiprocessor communication is off PORT_OFF(UBRRH,URSEL); //Change URSEL so I can ccess UBRRH UBRRH = 0x00; //Make sure they are all 0s UBRRL = 0x19; //Set baud rate to 2400 at 1MHz osc. UCSRC = (1<<URSEL) | (1<<UCSZ1) | (1<<UCSZ0); //8 data bits UCSRB = (1<<RXEN) | (1<<TXEN); //Enable Rx and Tx DDRD = (1<<DDD2); //Enable D2 for output for blinker LED PORTD = (1<<PORTD2); //Turn LED on initially int i,rx_data; for(;;) { for(i=32;i<127;i++) { while(!(UCSRA & 0x20)); //Wait until transmit buffer is empty UDR = i; //Put i into UDR if (UCSRA & 0x80) //If data recieved flag is set { rx_data = UDR; //Put recieved # into rx_data if ((rx_data % 10 == 0) && (rx_data != 0)) //If number is divisible by 10 and is not 0 FLIP_PORT(DDRD,DDD2); } pause(500); //Pause so I can actually see the blinking. } }}
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
Yep, break it down and test each. It could be noise but 19.2k Baud isn't that fast. You could try a slower Baud rate to see.How long and the wires at TTL levels? Does it work better with shorter wires? Something else to try is to twist together the RX, TX and ground wires to reduces noise pickup.It could still be a slight Baud rate mis-match. Have you checked the UART output bit timing of both processors with a scope? Does the Tiny use an internal RC clock? Have you checked its accuracy?