Could you please elaborate? What does "with clock" mean? In which clock you are referring to? And what kind of synchronization would that be?vinkad999 said:the remaining 1234 should generate pulses as 1
comes means it should generate 0001{binary format of one} with clock
and 2 means it should generate 0010 with clock and so on for 3 and 4.
Internal clock as i am using it in my project [internal 1Mhz].Here clock means for raising edge the data must be sampled.Suppose for low to high transition of a clock the bit 0 or bit 1 must be sent.Suppose if i send 1 in my data .For four clock pulses ,data 1 [0001 in binary] should be outputted.Here bit 0 is 1 for first clock pulse that should be outputted,for second clock pulse bit 1 must be outputted and so on bit 3.Could you please elaborate? What does "with clock" mean? In which clock you are referring to? And what kind of synchronization would that be?
So you want each time the system clock toggles, to buffer your data out is that it? But how are you going to do that? How are you going to catch up with your system clock?vinkad999 said:Internal clock as i am using it in my project [internal 1Mhz].Here clock means for raising edge the data must be sampled.Suppose for low to high transition of a clock the bit 0 or bit 1 must be sent.Suppose if i send 1 in my data .For four clock pulses ,data 1 [0001 in binary] should be outputted.Here bit 0 is 1 for first clock pulse that should be outputted,for second clock pulse bit 1 must be outputted and so on bit 3.
So you want each time the system clock toggles, to buffer your data out is that it? But how are you going to do that? How are you going to catch up with your system clock?
Is there any standard you want to follow like SPI or I2C? Or do it by software of your own?
You could do this with the help of a timer interrupt. In this way you will synchronize the data, obviously with slower clock than your oscillator's.
But in any case, you must give a more detailed description. You are going to communicate with what? Is your MCU master or slave? Please give a full application scenario, otherwise members will not be in position to help you even if they want to.
Alexandros
OK now we have some usuful information! :smile:vinkad999 said:I am going to communicate with rs232 and i am sending the data from hyper terminal to the microcontroller through rs232.Is that possible with system clock or can i use external clock??.I am sending the commands from hyperterminal .
You don't need something special for this. If you manage to send a single character succesfully, then the road is open to proceed as planned! ;-)vinkad999 said:There are three types of commands i am sending.Namely Level,Pulse and Data command.Data command is recognized by the command DE80 followed by the data[for exampleE801234 OR DE802567].
I have established the communication using the baud rate of 4800bps with 1mhz internal clock.Now how can i send the data that should synchronize with the clock.I need the code for that.OK now we have some usuful information! :smile:
No need for external clock. Let us first post the datasheet to have our reference.
http://www.atmel.com/Images/doc8155.pdf
So in page 172 in table 19-9 you can see that you have a maximum baudrate of 115200 for fosc=1MHz, and only if you use double speed.
Keep in mind that from the MCU side you need to have the exact same settings with hyperterminal to make it work (baudrate, stop bits, etc).
In chapter 19 (USART), several examples are given for USART initialization, transmit and receive. You can first follow these examples to easilly establish a valid communication with hyperterminal. I suggest to carefully read the whole chapter in any case.
As for hardware, you need to use an RS-232 driver like MAX232.
**broken link removed**
http://en.wikipedia.org/wiki/RS-232
Also the below references will help you to get you started with code and hardware.
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=45341
https://www.edaboard.com/threads/216000/
https://www.edaboard.com/threads/238236/#post1018972
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=48188
https://www.edaboard.com/threads/225604/
https://www.edaboard.com/threads/228501/
You don't need something special for this. If you manage to send a single character succesfully, then the road is open to proceed as planned! ;-)
Hope it helped,
Alexandros
I don't have the slightest idea of what you mean. The data are already synchronized. If you need to send those data at specific periods of time, then as suggested in earlier post, you can use a timer.vinkad999 said:Now how can i send the data that should synchronize with the clock.I need the code for that.
OK, I'll give you code for that a bit later.vinkad999 said:simple if i sen data command as DE801234 .DE80 is not a problem but 1234 should be outputted as in binary format as 0001[i.e 1]with 4 clock pulses for each and so on for 2[0010],3[0011],4[0100].
By reviewing this thread again, maybe you mean USART synchronous mode?vinkad999 said:Now how can i send the data that should synchronize with the clock.I need the code for that.
OK I assume that you are using a function to send serial data, let's call it send_char(), because I don't know the actual name you are using.vinkad999 said:simple if i sen data command as DE801234 .DE80 is not a problem but 1234 should be outputted as in binary format as 0001[i.e 1]with 4 clock pulses for each and so on for 2[0010],3[0011],4[0100].
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 void send_4_bit (unsigned char dec_ascii) { unsigned char dec = (dec_ascii & ~'0'); if (dec & 8) send_char('1'); else send_char('0'); if (dec & 4) send_char('1'); else send_char('0'); if (dec & 2) send_char('1'); else send_char('0'); if (dec & 1) send_char('1'); else send_char('0'); }
Code C - [expand] 1 2 3 4 5 6 7 8 send_char('D'); send_char('E'); send_char('8'); send_char('0'); send_4_bit('1'); send_4_bit('2'); send_4_bit('3'); send_4_bit('4');
I haven't used synchronous mode, but according to the datasheet you need to set UMSEL bit inside UCSRC register.vinkad999 said:I need the code for the data transfer that should synchronize with the clock.
The UMSEL bit in USART
Control and Status Register C (UCSRC) selects between asynchronous and synchronous oper-
ation. Double Speed (Asynchronous mode only) is controlled by the U2X found in the UCSRA
Register. When using Synchronous mode (UMSEL = 1), the Data Direction Register for the XCK
pin (DDR_XCK) controls whether the clock source is internal (Master mode) or external (Slave
mode). The XCK pin is only active when using Synchronous mode.
OK I assume that you are using a function to send serial data, let's call it send_char(), because I don't know the actual name you are using.
Now the function that sends the four bits should look like this:
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 void send_4_bit (unsigned char dec_ascii) { unsigned char dec = (dec_ascii & ~'0'); if (dec & 8) send_char('1'); else send_char('0'); if (dec & 4) send_char('1'); else send_char('0'); if (dec & 2) send_char('1'); else send_char('0'); if (dec & 1) send_char('1'); else send_char('0'); }
If you want to send DE801234 like your example, then the code would be:
Code C - [expand] 1 2 3 4 5 6 7 8 send_char('D'); send_char('E'); send_char('8'); send_char('0'); send_4_bit('1'); send_4_bit('2'); send_4_bit('3'); send_4_bit('4');
Please use this code and post back the results.
I haven't used synchronous mode, but according to the datasheet you need to set UMSEL bit inside UCSRC register.
One question is if you are going to be master or slave.
https://extremeelectronics.co.in/avr-tutorials/using-the-usart-of-avr-microcontrollers/
https://www.avrfreaks.net/index.php?name=PNphpBB2&file=printview&t=18526&start=0
As I said I haven't used synchronous mode, you could do some reading by yourself about AVR's USART.
It seems that if you are master, there's nothing more you should do except setting the UMSEL bit.
Hope this helps,
Alexandros
You must put more effort on this, the solution is given but you have to adjust it to your program. The scenario is that you have a 4-digit number and you want to split it into its digits and then send it to 4-bit format. The 4-bit code has been given and believe me, it is for general use. Now split a number into its digits? Please tale a look at the below edabord thread, it's all in there:i need the code for general suppose if i send DE807654 OR DE809999
It seems that you don't even take a quick look to the datasheet. Whatever help you will get from a forum, cannot replace your own effort. As already told earlier, it is all in the USART chapter of the datasheet.i need to show the data for raising edge of the clock
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?