|
楼主 |
发表于 2008-11-18 20:44:11
|
显示全部楼层
与CY 支持工程师的对话(时间顺序从下往上,目前还没有CLOSE):
=====Cypress Response Sachin Gupta | 11/18/2008 07:37 AM | Web
Yeah, you are right. It is advised to keep High-Z pins to be tied at some fixed level externally. There is no other solution. //!!!(2)
Best regards,
Sachin
===== Customer Comment Ma Chao | 11/18/2008 07:30 AM | Web
But you have not got it correctly.
Not only PRT0DR |=0x01 but also PRT0DR &= 0xFE is only OK for P0[0] . BUT MAY BE CHANGGE OTHER VALUES OF PRT0DR REGISTER THAN PRT0DR[0]!!! Because the other pins status is not the same as the values of port register.
===== Cypress Response Sachin Gupta | 11/18/2008 07:23 AM | Web
your reset pin may be at any logic as you are driving the line to High-Z(means unconnected). So it may be at any logic according to noise.
===== Cypress Response Sachin Gupta | 11/18/2008 07:18 AM | Web
yeah! now you have got it correctly.
===== Customer Comment Ma Chao | 11/18/2008 07:07 AM | Web
Apart from that when you want make P0[0] high, then you write:
PRT0DR |=0x01;
This instruction will effect on P0[0] not other pins. Because you are performing the OR operation. If you OR any pin which '0' then pin value will not change.
If you want to clear the P0[0], then you use
PRT0DR &= 0xFE;
Now P0[0] will be cleared. But other pins will not be effected. As performing AND operation with '1' will not effect the original pin status of pins other than P0[0].
The key is when change P0[0], I WILL NOT CHANGE OTHER VALUE OF PORT0 REG THAN P0[0]. the other pin status may be DIFF from REG!
===== Customer Comment Ma Chao | 11/18/2008 06:50 AM | Web
LCD only use 7 pins, but PORT 2 have 8 pins,
OK. Let us talk abour LED UM ,for example, use PORT0.0 for LED, and I also use PORT0.1 for controling a RESET pin of other chip.
beging I will set my RESET pin HZ (PORT0.1 works as Open Drain,Drives Low ):
PRT0DR |=0x02; // SET port0.1 PIN High-Z
after that it comes your LED UM
PRT0DR |= 0x01; // turn on LED
OK, The LED UM must frist read PRT0DR, but is PIN value not REG. At this time wath value is PORT0.1 that is High-Z state? Is "1" or "0"?
MAYBE "0"!! THEN PRT0DR = 0x00(value of pins) | 0x01, Yes, the LED is turned on, but what about my RESET pin? IS "1" OR "0"?
===== Cypress Response Sachin Gupta | 11/18/2008 06:14 AM | Web
You are not supposed to use same pins for both purpose. For example if you are using port 2 for LCD then you should not use the port for other things.
Apart from that when you want make P0[0] high, then you write:
PRT0DR |=0x01;
This instruction will effect on P0[0] not other pins. Because you are performing the OR operation. If you OR any pin which '0' then pin value will not change.
If you want to clear the P0[0], then you use
PRT0DR &= 0xFE;
Now P0[0] will be cleared. But other pins will not be effected. As performing AND operation with '1' will not effect the original pin status of pins other than P0[0].
Let me know if it clears your doubt.
Best regards,
Sachin
===== Customer Comment Ma Chao | 11/18/2008 06:02 AM | Web
Thanks very mush for your kindly support service. Are you speaking chinese,? My english speaking is poor. So I like type same words to you.
Yes, your LCD used pin is right, LCD no problem. But the LCD UM may changed the Other PIN VALUE that I used at the same port as the LCD!
In API like for LCD, we do not need to read the data which I have written to that port (you must read port, but this port have other pin that LCD no used be using by I ).
So, I do not need to keep any temp variable . I just need to read input pins (this pins also include my used pin, not the PINS that only LCD used) and that can I do ass I told earlier (so my pins also be chenged! And I had not known! ).
===== Cypress Response Sachin Gupta | 11/18/2008 05:21 AM | Web
In API like for LCD, we do not need to read the data which I have written to that port. So, I do not need to keep any temp variable. I just need to read input pins and that can I do ass I told earlier.
If you still have any doubt regarding this issue, then please give me your contact number. I will give a call to you.
Best regards,
Sachin
===== Customer Comment Ma Chao | 11/18/2008 05:18 AM | Web
LED,LCD......many user module need change the port pin. Do they use temporary variable? When a pin used by my code and a pin used by LED MU are at the same port, what can I do? Using the temporary variable?
===== Cypress Response Sachin Gupta | 11/18/2008 05:01 AM | Web
which user module you are talking about?
Best regards,
Sachin
===== Customer Comment Ma Chao | 11/18/2008 04:37 AM | Web
ok.
But what about the USER MU? is it using the temporary variable? And how I use the temporary variable in my code with USER UM togather?
===== Cypress Response Sachin Gupta | 11/18/2008 03:33 AM | Web
I gave you one example about strong and High-Z mode. If a pin is configures for output, then if you write
PRT0DR = ---;
Then the pin status will be the same what you write on that.
No, PSoC do not have commands for bit operations. Whenever you read the port, you can read pin value only. You will need to use one temporary variable to keep track of written data. //!!!!(1)
Let me know if I may go ahead and close this case.
Best regards,
Sachin
===== Customer Comment Ma Chao | 11/18/2008 03:00 AM | Web
so problem will come. if do this:
PRT0DR |= 0x01; // works as Open Drain,Drives Low, only set port.0 High-Z
PRT0DR |= 0x02; // only set port.1 high
as you sey: "your pin P0[0] will become '1' for sure. But if you keep the mode as High-Z then it will not effect the pin status." . after the second sentens the port.0 PIN maybe not be High-Z!
I will say ,the PSoC have not the bit oprations and must use READ-MODIFY-WRITE to change a bit. As this time the beste way is read port register not PIN value!
I will knew how can read the value of port register?
===== Cypress Response Sachin Gupta | 11/18/2008 12:31 AM | Web
It depends upon the drive mode which you have select for a particular pin. If you select port 0 as Strong and then write
PRT0DR |= 0x01; //only set port.0 high,
your pin P0[0] will become '1' for sure. But if you keep the mode as High-Z then it will not effect the pin status.
Let me know if it answers your question.
Best regards,
Sachin
===== Customer Comment Ma Chao | 11/17/2008 11:50 PM | Web
In same actual situation, the PIN value is not the same as port regist. At this time, when you change one port bit maybe another port bit also be changed. For example:
PRT0DR |= 0x01; //only set port.0 high
PRT0DR |= 0x02; //only set port.1 high
after the first sentens the PRT0DR register is 0x01, but the port.0 PIN maybe not be high. So the second sentens may not only set port.1 high (needed) but also clear the port.0(not needed!)
===== Cypress Response Sachin Gupta | 11/17/2008 07:16 PM | Web
Dear Ma Chao,
I would like to give you a broad idea about ports. Basically ports uses that shadow register. When you write anything on port, that is written in the PRTxDR write register:
PRT0DR = ------;
This is the internal register.
When you read the port:
------ = PRT0DR;
This is port pin itself.
Let me know if it clears your doubt.
Best regards,
Sachin
===== Customer Comment Ma Chao | 11/17/2008 10:24 AM | Web
Thanks for your response.
Thinking of that the PIN value maybe not same as PRT0DR REG, when you change one port bit maybe another port bit also be changed?
===== Cypress Response Sachin Gupta | 11/17/2008 02:08 AM | Web
Dear Ma Chao,
Yes, PRT0DR &= 0xBF is same as PRT0DR = PRT0DR & 0xBF.
These instructions read the pin status, perform & 0xBF and then output it on PRT0DR itself.
PRT0DR on the right hand side is the actual PIN value.
To read PRT0DR PIN value use:
variable = PRT0DR; //variable is any byte size variable
Let me know if it answers your questions.
Best regards,
Sachin
本贴被 machao 编辑过,最后修改时间:2008-11-19,00:11:38. |
|