ATmeag128 8Mhz with Z85c30 SCC(zilog)

Hello.

I am coding to build-up SDLC(HDLC) in z85c30 with MCU, ATmega128.

I am trying to build-up SDLC(HDLC) protocal H/w environment is z85c30(CMOS) with 4.91520Mhz crystal for PCLK. Also, z85c30's D0~D7 is connected with MCU in un-multiplexe mode(=direct)

communication specification is as below - 38.4kbps - NRZI mode - Response time: 50ms - Address: Lower=70h Higher=05h - control field: 13h - Information field if first text = 20, SDR(Master -> Slave) if first text = 30, SD(Slave -> Master)

For SDR, Information field length is 20 + 7bytes (8bytes) For SD, Information field length is 30 + 11bytes (12bytes)

with this specification, I do code as below. For Rx, I use interrupt drived method, and for Tx just polling method used.

Now, this code works on only Rx. Tx does not work, which means master could not get data. I can receive data, but can not send(Tx) to master device.

Could you please check this procedure in c lang with any advice? I hope I may get some helpful hands from your side.

---------code in c lang: Mai function------------------------------------- void main(void){ __disable_interrupt(); //All interrupt disable

SETBIT(INTACK); //NO interrupt ack. z85c30_set(); //sub-function will be shown below z85c_enable(); //sub-function will be shown below

__enable_interrupt(); //All interrupt enable

while(1){ switch(sdlcstep){ case 0: //Rx start Write_reg(5,0x60); //Tx 8bits, Tx disable Write_reg(3,0xcc); //Rx 8bits, Rx CRC enable, Addres

search mode Write_reg(3,0xcd); //Rx enable Write_Reg(1,0x10); //Rx int on all received characte

or special condition break; case 1: //If Rx Ok. if(RxOk){ for(icnt=4;icnt

Reply to
sebastiankoo
Loading thread data ...

On Mon, 25 Feb 2008 09:41:22 -0600, "sebastiankoo" wrote in comp.arch.embedded:

[snip]

It's been a long time since I programmed a Z85C30, and then it was on a Z80. I think the last time was before AVR architecture even existed. But I do see a problem in your C code...

In this case you do not modify the value of "sdlcstep". You don't show the definition or initialization of this variable in the code you posted, but I assume it has external linkage and static storage duration, so it is initialized to 0.

The first time into this loop, the value is 0. In the case for the value of 0, you never change the value. So your loop will always execute this case forever.

So you never get farther into your state machine, never get to where you try to transmit.

--
Jack Klein
Home: http://JK-Technology.Com
 Click to see the full signature
Reply to
Jack Klein

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.