Search for Usart in Topics


Help with AVR USART?

Hello... Im trying to make a set of RF remote switches using an atmega16.  I want to push a momentary button on the Tx board and effectively have a relay connected to one of the output pins TRIGGERED on the Rx board. I have attached the code I did for this, I send the entire data=PINC; through uart and catch it on the other end and do PORTC=data; but with this approach I would not be able to TRIGGER the output pin. Please help.....  TX side code.... #include #include #include "usart.h" void main() {  //Initialize the USART with Baud rate = 2400bps  USARTInit(416);  //Enable Internal Pullups on PORTC  PORTC=0xFF;  /* Keep transmitting the Value of Local PORTC to the Remote Station. On Remote RX station the Value of PORTC sent on AIR will be latched on its local PORTC */ uint8_t data; while(1) { data=PINC; /* Now send a Packet Packet Format is AAZ total Packet size if 5 bytes. */ //Stabilize the Tx Module By Sending JUNK data UWriteData('J'); //J for junk //Send 'A' UWriteData('A'); //Send Another 'A' UWriteData('A'); //Send the data; UWriteData(data); //Send inverse of data for error detection purpose UWriteData(~data); //End the packet by writing 'Z' UWriteData('Z'); //Wait for some time _delay_loop_2(0); _delay_loop_2(0); _delay_loop_2(0); _delay_loop_2(0); } } RX Side code #include #include "usart.h" void main() { uint8_t i; //Clasical loop varriable uint8_t packet[5],data=0; DDRC|=0xFF; //All Output //Initialize the USART with Baud rate = 2400bps USARTInit(416); /* Get data from the remote Tx Station The data is the value of PORTC on Remote Tx Board So we will copy it to the PORTC of this board. */ while(1) { //Wait for a packet while(!UDataAvailable()); if(UReadData()!='A') continue; while(!UDataAvailable()); if(UReadData()!='A') continue; while(UDataAvailable()!=3); //Get the packet for(i=2;i<5;i++) { packet[i]=UReadData(); } //Is it ok? if(packet[2]!=((uint8_t)~packet[3])) continue; if(packet[4]!='Z') continue; //The packet is ok data=packet[2]; //Now we have data put it to PORTC PORTC=data; } }  

Question by pro2xy  


What V.Smile hacks have been done?

I would like to develop games for the V.Smile, but I don't know how I should do it. However, upon disassembling a V.Smile Plus controller (which had labeled communication pins), I found the V.Smile controller pinout: 1=VCC (3V) 2=RTR (to request a report from the controller) 3=RX 4=GND 5=TX 6=RTS (to prepare the controller to change the state of an LED) Also, if you want to make your own controller, make sure that it is polarity-protected, because the power-down voltage can be as much as -1V.

Question by VirtualBoxer    |  last reply


PIC18LF4680 microcontroller and usb ttl for usart / serial data

Hi everyone. I want to know if it's possible to connect a ttl device directly to my PIC18LF4680 for serial communication via USART . I can connect the ttl device directly to my Arduino Uno without issues. The ttl  device has 6 pins (dtr , rxd , txd , vcc(3.3v or 5v) , cts, gnd) . I have two different codes snippets below that perform USART communication. * Version one(I) utilizes the "usart.h" peripheral library. * Version two(II) uses "TXREG" and "RCREG" for sending and receiving data. Both versions run well in my virtual environment (Proteus 8 Professional), but not in the real world environment. Am I missing a step? Do I need a special library? Or is it not possible with this chip? VERSION (I)   ------------------------ #include "fuses.h" #include #include #include #include void main(void) {         TRISB = 0x00;     OSCCON = 0x76;          // 8mhz (0111 0110)          LATBbits.LATB4 = 0;      LATBbits.LATB1 = 0;      LATBbits.LATB0 = 0;          unsigned char txt1[] = "Hello World \r\n";     unsigned char txt2[] = "Enter a number.... \r\n";         CloseUSART();         OpenUSART(USART_TX_INT_OFF &             USART_RX_INT_OFF &             USART_ASYNCH_MODE &             USART_EIGHT_BIT &             USART_CONT_RX &             USART_BRGH_HIGH &             USART_ADDEN_OFF ,             52);             for(int x=0;x<=20;x++){__delay_ms(50);}         // write/send intro to PC         while(BusyUSART());     putsUSART((char *)txt1);         for(int x=0;x<20;x++){__delay_ms(50);}         while(BusyUSART());     putsUSART((char *)txt2);             for(int x=0;x<20;x++){__delay_ms(50);}             while(1){         sdata = ReadUSART();                 switch(sdata){             case '1':                 LATBbits.LATB4 = 1;                  LATBbits.LATB1 = 0;                  LATBbits.LATB0 = 0;              break;                         case '2':                 LATBbits.LATB4 = 0;                 LATBbits.LATB1 = 1;                  LATBbits.LATB0 = 0;                             break;                         case '3':                 LATBbits.LATB4 = 0;                  LATBbits.LATB1 = 0;                  LATBbits.LATB0 = 1;              break;                                     default:                 LATBbits.LATB4 = 0;                 LATBbits.LATB1 = 0;                 LATBbits.LATB0 = 0;              break;         }     }     } -------------------------------------------- VERSION (II) --------------------------- #include "fuses.h" #include #include #include #define STRLEN 12 volatile unsigned char t; volatile unsigned char rcindex; volatile unsigned char rcbuf[STRLEN]; void USART_init(void){         TXSTAbits.TXEN = 1;     // enable transmitter     TXSTAbits.BRGH = 1;     // high baud rate mode     RCSTAbits.CREN = 1;     // enable continous receiving     // configure I/O pins     TRISCbits.TRISC7 = 1;     // RX pin is input     TRISCbits.TRISC6 = 1;     // TX pin is input (automatically configured)     SPBRG = 52;                PIE1bits.RCIE = 1;      // enable USART receive interrupt     RCSTAbits.SPEN = 1;     // enable USART         } void USART_putc(unsigned char c) {     while (!TXSTAbits.TRMT); // wait until transmit shift register is empty     TXREG = c;               // write character to TXREG and start transmission } void USART_puts(unsigned char *s) {     while (*s)     {         USART_putc(*s);     // send character pointed to by s         s++;                // increase pointer location to the next character     } } void main(void) {         OSCCON = 0x76;          // 8mhz (0111 0110)         USART_init();         USART_puts("Init complete! \n");     INTCONbits.PEIE = 1;    // enable peripheral interrupts     INTCONbits.GIE = 1;     // enable interrupts     while(1)     {     }     } void interrupt ISR(void) {     if (PIR1bits.RCIF)  // check if receive interrupt has fired     {         t = RCREG;      // read received character to buffer         // check if received character is not new line character         // and that maximum string length has not been reached         if ( (t != '\n') && (rcindex < STRLEN) )         {             rcbuf[rcindex] = t; // append received character to string             rcindex++;          // increment string index         }         else         {             rcindex = 0;        // reset string index             USART_puts(rcbuf);  // echo received string         }         PIR1bits.RCIF = 0;      // reset receive interrupt flag     } } ------------------------------------------------------------ Any and all help is appreciated. Thanks!

Topic by newbie14    |  last reply


Palm Universal Wireless Keyboard disassembly?

I'm toying with the thought of adapting my Palm Universal Wireless Keyboard to work with Bluetooth.  Currently, it sends irDA data at 9600 baud.  This should be decodable using an xmega's usart which has an irDA mode.  One could even bypass the IR emitter, as there are exposed contacts in the base where one can catch the signals prior to irDA transmission (at 1.5V high  / 0.5V low levels). My question is: Does anyone know how to disassemble the keyboard?  I don't see any screws anywhere.

Topic by arpruss    |  last reply


3 wire interface (GND, VCC, DATA)? Answered

Hi guys,   I'm trying to reverse the communications on a project I have at the moment which seems to be using a 3 wire serial interface (GND, VCC, DATA).  My goal would be to replicate the communications with an arduino or similar, however i'm not 100% sure what serial protocol it's using.   The device is using an Atmel ATMEGA168 and the pcb is covered in conformal coating, so I haven't had a whole lot of luck tracing the pins. I'm not overly aware of many one-wire communications protocols.  The datasheet says the ATMEGA supports various peripheral features, including SPI, USART, 2-wire serial (Philips I2C) (among others), however the GND, VCC, DATA configuration doesn't seem to fit with any of the supported protocols (i.e. there's no clock line and only a single data line).   The captures i'm getting seem to indicate that it's an 8-bit binary protocol.  I was going to try to decode it manually and attempt to reproduce it, however would be grateful if someone recognizes it and can point me in the right direction. Does anyone know any protocols / configurations this could be?  Example screenshot attached. Any help would be greatly appreciated!  Thanks!

Question by ikarus6    |  last reply


24 x 24 LED Matrix Project

I would like to share with you all an awesome project and some doubts and questions related to the same. This is a 24 x 24 LED Matrix project taken from here. All the data is taken from the same link. 24×24 LED dot matrix -->   This is pretty old circuit but I found it interesting to describe here. 24×24 LED display is formed by using 9 8×8 Dot LED matrix displays, that are connected to AT90S2313 MCU. MCU scans an indicator lines in series. Special PC program is written which allows drawing images on screen and transfer them via COM port to device. You can send images in series what gives an animation effect.   Circuit is was built using obsolete AT90S2313 MCU which can be replaced by Attiny2313 MCU with minor modifications of firmware. To make program work you event don’t need to connect device to computer COM port. You can store images in other master MCU EEPROM memory Each received byte from UART is immediately sent to 8 LEDs, second byte to next 8 LEDs and so on. Bytes has to be sent one by one without delay. USART is working at 115200 baud, 8bits, no parity. ---------------------------------------------------------------------------------------------------------------------------------- THE PROBLEMS >1>I really dont know if the circuit is good or not tell me if it is going to work. >2>I cant get 8x8 dot matrix displays so i am going to normal leds to a 24x24 one. >3>I have never worked with bus before (the bold red lines in the circuit) so i dont know how to connect it. >4>The schems are segmented i am finding it hard to figure out how to connect some of the segments. >5>Also i need to know how to hook it up to my pc. >6>I have never done programming so i need to know how to program the ic. THANK YOU I couldnt get the images uploaded nicely so i linked them. 1 2  

Topic by science_freak    |  last reply