NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Support Forum » modifying Baud rate is it related to ADC
October 16, 2010 by esc |
Hello, I need some helping trying to understand something. In my project if I need to lower the baud rate of sending data out of the TXD pin of the MCU (b/c for my wireless transmission the 115200 is to high..i need like 2400). Do I need to also modify the related ADCSRA bits? I saw in the temp project the ADCSRA were modified to support the 1/128 which if we take the clock speed multiplied by that value we get the 115200. Are ADC and UART baud rate suppose to be related or just a coincidence? I guess I am wondering if the ADC has to run at the same freq as the baud rate. If so I didn't see from the guide anything higher than 128 to get to 2400 when multiplied. I am probably completely off base here and not making sense (heck I am even confusing myself :) ) I am just trying to wrap my head around this at a high level. Thanks, esc |
---|---|
October 16, 2010 by Rick_S |
If you are using standard Nerdkits files, the baud rate is set in the file uart.c found in your libnerdkits directory. If you look at that program in the uart)init() function, you will see the registers used for setting the baud rate.
Now if you look at the datasheet for the USART0 section you'll find tables that tell you what to set the registers to, to achieve many different baud rates. In this case, to set 2400bps with a 14.7456 clock, UBBRn would be 383 or UBBR0H = 1 & UBBR0L = 127. (I think I got that right :) ) What you could do, is add another function to uart.c that would init at the desired baud rate or copy uart.c to another file that has been modified. That way you can keep the original intact. Hope that helps a bit, Rick |
October 16, 2010 by esc |
ok thank you. I guess what I was getting confused about was in the tempsensor.c file we have this line: // set analog to digital converter // to be enabled, with a clock prescale of 1/128 // so that the ADC clock runs at 115.2kHz. ADCSRA = (1<<ADEN) | (1<<ADPS2) | (1<<ADPS1) | (1<<ADPS0); Do I have to modify these so the ADC runs at 2400 too? I didn't see in the guide how to do that. Or was the fact the ADC clock is set at 115.2kHz and the UAR is at 115200 just a coincidence and they are really unrelated? Thanks again, Scott |
October 16, 2010 by Rick_S |
Other than they both are dependent upon the crystal speed, they are unrelated. They each have their own registers for their setup. Rick |
Please log in to post a reply.
Did you know that you can make a capacitive proximity sensor with some aluminum foil and paperclips? Learn more...
|