m16c ports

Hi All, I use m16c M30624FGPFP (24MHz) and I drive S1D13305(SED1335). If I use P5 as data port and P6 as control port Everything is OK. But if I use P0 as data port and P1 as control port display doesn't run. Do you know any difference between ports? or P0 and P1 need extra init to bidirectional IO?

Reply to
icegray
Loading thread data ...

If I remember correctly, P0 is used for the uart which is used to flach the device over a serial cable. That said it's becoming initialized by the boot loader code in Flash sector A. However that's out of the top of my head, so use this info with care:-). The datasheet should give you the right answer.

Markus

Reply to
Markus Zingg

I reckon it would of taken you longer to post your message than it does to read the user manual.

Although it's been quite a few years since I've handled this beast, yes, there are differences. P0,1 are the data bus in memory modes. Make sure you are in single-chip mode (CNVss pin and Processor mode register) and that the P1 port control register is cleared etc.

If in doubt, read the manual.

*Peter*

icegray wrote:

Reply to
Peter Jakacki

Thanks your answer, I use as single chip mode and Manual says if you use single chip all pins are IO.

Reply to
icegray

We use an M16C for our current products. One of them uses P0 for a Bidirectional Databus and P1, P2 and P5 for the Control of 74HCT541 for inputs and 74HCT574 for outputs with the P0 BUS, also on the same bus is an LCD 2x20 display based on the HD44780. Similar requirements to yourself.

Some of the init code for the ports //Pullup resistance is only connected when direction register is set for input

pu00 = 1; // pull up for P0_0 to P0_3 pu01 = 1; // pull up for P0_4 to P0_7 pu02 = 0; // no pull up for P1_0 to P1_3 pu04 = 1; // pull up for P2_0 to P2_3 pu10 = 1; // pull up for P4_0 to P4_3 pu11 = 1; // pull up for P4_4 to P4_7

//Direct register Stuff, force to inputs p4 = 0xff; //set port data lines to high pd4 = 0; //set port data lines to INPUTS

p0 = 0xff; //set port data lines to high p1 = 0xff; //set port data lines to high pd0 = 0x00; //set port data lines to INPUTS

Now a read from an HCT541 on the BUS, OE connected to P1_7

pd0 = 0x00; //tristate data lines (make as inputs) pd1_7 = 1; //ensure Port direction to OUTPUT p1_7 = 0; //Pull OE of HCT541 low data = p0; //Read data from bus p1_7 = 1; //OE of HCT541 High

Now a write to an HCT574 on the BUS, STB connected to P1_6

p0 = data; //Prepare BUS output register first to prevent noise. pd0 = 0xff; //set port data lines to outputs // //Ensure pd1_6 is always OUTPUT and P1_6 = 0 p1_6 = 0; //Prepare p1.6 = 0 before setting direction pd1_6 = 1; //STB of 74HCT574 = LOW //Now Strobe the Data in p1_6 = 1; //STB of 74HCT574 = HIGH p1_6 = 0; //STB of 74HCT574 = LOW //Now Leave BUS in Tristate condition p0 = 0xff; //set port data lines to high pd0 = 0x00; //tristate data lines (make as inputs)

After working with the P0 Bus I always leave it configured for INPUT, and always on the control Buses force the Control PIN to OUTPUT MODE.

Hope I've high lighted something you've missed.

Reply to
sivadnz

On some M16C chips port direction registers for SOME ports may be write protected usign protect registers. In some chips the protected one is P1 dir register. Go check the description of direction register in your chip hardware manual.

Reply to
Grzegorz Mazur

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.