Microchip
直播中

黎菁菁

8年用户 574经验值
私信 关注
[问答]

在24FJ中动态更改可编程引脚

我想用我的24FJ256GB210的DS1302 RTCC芯片,我把自己画成一个角落,制作了一个相当复杂的PC板,里面有一个连接器,它不容易被重新分配到I2C(这看起来是最好的方式去使用这个芯片)。我已经提出了一种使用SPI和可重新编程引脚的方案——通过RPS在SDO和SDI之间进行实时切换,并且使用未使用的RP作为虚拟I/O,它改变了对我的2路数据引脚的补充。我的问题是简单地切换RPS是否是可接受的24。FJ练习。这样来回颠簸有没有解决问题的时间?我还没试过呢!请再问一个问题。如果我想把一个非GPIO角色的RP改回到GPIO,这仅仅是通过声明tiS寄存器来完成的吗?如果在同一个原始应用程序中有其他的PIN,它们会受到影响吗?

以上来自于百度翻译


      以下为原文

    I want to use a DS1302 RTCC chip with my 24FJ256GB210 and I have painted myself into a corner having made a rather complex PC board with a connector in place which can't easily be reassigned to I2C (which looks the best way to go with this chip). I have come up with a scheme to use SPI in conjunction with the reprogramable pins - changing between SDO and SDI on the fly via the RPs and having an unused RP as a dummy I/O which changes in complement to my 2 way data pin.

My question is whether simply switching RPs on the fly is an acceptable 24FJ practice. Is there any settling time when flipping back and forth in this way? I haven't tried it yet!

One more question please. If I want to change an RP from a non GPIO role back to GPIO is this simply done by asserting the TRIS register? If there were other pins in the same original application are they affected?

回帖(3)

吴键洪

2018-9-7 15:18:47
I2C使用“BIT Butin”(即手动引脚操作)实现起来非常简单,所以像RTC这样的低速设备可以通过任何两个GPIO引脚来控制。如果使用PPS,是的,如果您还没有设置它只能一次性使用(如果您的PIC具有该特性),那么您可以快速切换引脚。零到PPS寄存器禁用PPS。编辑:零到输出寄存器,0xB111111到输入寄存器,以恢复到默认赋值。

以上来自于百度翻译


      以下为原文

    I2C is pretty simple to implement using "bit banging" (i.e. manual pin manipulation), so a low speed device like an RTC can be controlled via any two GPIO pins.
 
If you use PPS, yes, you can switch pins rapidly if you haven't set it to be only doable once (If your PIC has that feature).
 

No, you write zero to the PPS register to disable PPS.
 
Edit: Zero to output registers, 0xb111111 to input registers to revert to default assignment.
举报

倪梁靓

2018-9-7 15:27:33
谢谢你,我喜欢你的建议。自从我停止使用汇编程序以来,我没有做过一些敲击,但我只写了几行C,你说得对,它其实很简单,当然比我的想法简单。

以上来自于百度翻译


      以下为原文

    Thanks qɥb -  I like your suggestion. I haven't done bit-banging since I stopped using assembler but I just put down a few lines of C and you're right it's actually pretty simple and certainly simpler than my idea.
举报

杨玲

2018-9-7 15:33:59
第一次改变它们就像第二次改变它们一样“飞黄腾达”。你为什么期望会有不同?

以上来自于百度翻译


      以下为原文

   
 
Changing them the first time is just as "on the fly" as changing them the second time.  Why would you expect there to be a difference?
举报

更多回帖

发帖
×
20
完善资料,
赚取积分