usart synchronous on ATMEGA 2560

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Dears

I need help and information build program to use serial synchronous in atmega 2560. I write code  on serial2 but in xck2 pin I not see clock.

baud = 51; // for example

UBBR2H = (baud >> 8);
UBBR2L = baud; 

UCSR2A = 0;
UCSR2C = 0x46;

 

PinMode(14 , OUTPUT);   // 14 pin number xck2

 

sbi(UCSR2B,RXEN2);

sbi(UCSR2B,TXEN2);

 

clock is not on xck2. what is my wrong?

Last Edited: Tue. Oct 17, 2017 - 03:30 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I worked with synchronous serial communication in my first real job in the early '70s, as one could get a bit more throughput on e.g. 2400 bps leased connection with sync versus async and the needed start/stop bits.

 

But never since. ;)  So I'm curious as to what you are driving.

 

fbkian wrote:
UCSR2B = (1 << RXEN) | (1 << TXEN);

So you decided not to use magic numbers here, but in

fbkian wrote:
UCSR2C = 0x46;
you are going to make me look it up...

 

OK, I'll agree "sync" and "8-bit".

 

I take it this is Arduino?  What pin mapping is used, such that 14 is XCK2?  Is it actually connected to PH2 on your particular Arduino board?

 

Not if it is a "standard" board...

 

I don't see >>any<< of the XCK pins mapped to an Arduino pin...

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

fbkian wrote:
PinMode(14 , OUTPUT); // 14 pin number xck2

 

xck2 is pin 14 of the chip, but it is not Arduino digital pin 14! 

You seem to be confused about how Arduino pins are numbered.

 

See circuit schematic here: https://www.arduino.cc/en/Main/a...

The pin you seek is not brought out so it can be used on this circuit board.

 

Like Theusch, I too am curious about your use of sync serial comms.

 

Jim

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Like Theusch, I too am curious about your use of sync serial comms.

    One application you are seeing every days is the PDI interface. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

it is not important. i connected wire wrap to pin 14 for use xck2.  in arduino uno pin 4 is xck0. i try on uno but xck0 has not atcive. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

fbkian wrote:
it is not important.

Yes, it is.

 

fbkian wrote:
i connected wire wrap to pin 14 for use xck2.

Fair enough patch, assuming you went from PH2.  HOWEVER, you are making PJ1, digital pin 14, an output.  So at best PJ1 is going to "fight" with the signal from PH2.  And you do not show making PH2/XCK2 an output.  So your symptoms are not unexpected.

 

[Now you are going to make me look again ... is XCK direction overridden like TXD is?  No; in fact:

When using synchronous mode (UMSELn = 1), the Data Direction Register for the XCKn
pin (DDR_XCKn) controls whether the clock source is internal (Master mode) or external (Slave mode).
 

I was wondering how master/slave was distinguished -- you need to make PH2 an output for "master" to generate the clock.]

 

fbkian wrote:
in arduino uno pin 4 is xck0. i try on uno but xck0 has not atcive.

I'll agree that on a Uno Digital Pin 4 is XCK/PD4.  So did you make PD4 an output on the Uno?

 

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.