完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我想让这个函数在XC8中工作。我对C还不是很好,但是我明白我需要做什么。它发送了第七个(最左边的?)位,然后将剩下的剩余位全部移位并重复,直到字节被发送。定时要求要求数据以这种方式发送。有更有效的方法吗?内联空SDENTEL字节(无符号char字节){for(unChar char位元=0;位& lt;8;位++){sEndoBIT(位读(字节,7));字节& lt;& lt;=1;}
以上来自于百度翻译 以下为原文 I am trying to get this function to work in XC8. I am not that good with C yet but I understand what I need to do. It sends the 7th (Left Most?) bit and then shifts all of the remaining bits left and repeats until the byte is sent. Timing requirements require the data to be sent this way. Is there a more efficient way? inline void sendByte( unsigned char byte ) { for( unsigned char bit = 0 ; bit < 8 ; bit++ ) { sendBit( bitRead( byte , 7 ) ); byte <<= 1; } } |
|
相关推荐
11个回答
|
|
“字节& lt;lt;=1”;可以用一个汇编程序来完成,这样就相当有效了。你没有显示sdBIT()函数的代码,所以我不能评论这是多么有效。如果你把循环数减少到零,你的循环会更有效,因为汇编程序减量指令。自动测试零。
以上来自于百度翻译 以下为原文 Well "byte <<= 1"; can be done with a single assembler instruction, so that's pretty efficient. You did not show the code for the sendBit() function, so I can't comment how efficient that is. Your loop would be more efficient if you counted down to zero, because the assembler decrement instruction automatically tests for zero. So: for( unsigned char bit = 0 ; bit < 8 ; bit++ ) { ... } becomes unsigned char bit = 8; do { ... } while (--bit); |
|
|
|
SunBIT()需要在AsSeBube中完成,我还没有翻译它,但是我需要在满足时序要求的同时发送一个字节的比特。10111011StEntDeStayDeSt1发送1发送1个发送1ASM易失性(“SBI%[PORT],%[BIT] NT””RePt%[OnCyr] nt“NOPNT”“.EnDR”。n “”CBI%[端口],%[BIT] n “”RePt%[OpCalv] nt'“nopnt”“.nd\t”::(端口)“i”([SfRixIO-AdDr(端口)),[BIT]“i”(bit),[OnCalv]“i”(NSU-toOyLoad(T0H)- 2),[OfByc]“I”(NSth-To-循环(T0L)-2));
以上来自于百度翻译 以下为原文 The sendbit() needs to be done in assebmly, I have not yet translated it but I need to send the bits of a byte in order while meeting the timing requirements. 10111011 send 1 send 0 send 1 send 1 send 1 send 0 send 1 send 1 asm volatile ( "***i %[port], %[bit] nt" ".rept %[onCycles] nt" "nop nt" ".endr nt" "cbi %[port], %[bit] nt" ".rept %[offCycles] nt" "nop nt" ".endr nt" :: [port] "I" (_SFR_IO_ADDR(PORT)), [bit] "I" (BIT), [onCycles] "I" (NS_TO_CYCLES(T0H) - 2), [offCycles] "I" (NS_TO_CYCLES(T0L) - 2) ); |
|
|
|
如何将最左边的位发送到SDENBIT函数。我想它会像一个软件SPI比特爆炸,但我找不到命令使用。
以上来自于百度翻译 以下为原文 How do I send the left most bit to the sendBit function. I assume that it would be like a software SPI bit bang, but I cannot find the command to use. |
|
|
|
还有什么要使用sDeTBIT()函数吗?就我个人而言,我只需要在汇编程序中做所有的事。在编译程序中完成整个字节并做循环。在C中,我会做一些类似的事情,把比特7转换成布尔值。
以上来自于百度翻译 以下为原文 Is anything else going to use the sendbit() function ? Personally, I'd just do the whole lot in assember. Pass the whole byte and do the loop in assembler too. To do it in C, I'd do something like sendBit((byte & 0x80) != 0); Which converts bit 7 to a boolean value. |
|
|
|
谢谢,这是我试图转发的ARDUNO代码,HTTPS://GITHUBCOM/BigJOH/SimeNopixelDeMo/Bulb/Mask/ SimeNopixelDeMo/SimeNeopixelDeMo.iNi太累了,无法继续今晚。明天我会尝试更多。
以上来自于百度翻译 以下为原文 Thank You, This is the Arduino code that I am trying to port over, https://github.com/bigjosh/SimpleNeoPixelDemo/blob/master/SimpleNeopixelDemo/SimpleNeopixelDemo.ino I am too tired to continue tonight. I well try more tomorrow. |
|
|
|
现在,如果你在第一篇文章中提到你正在和WS28 12对话,你会得到更多的反馈。有很多关于这个芯片的话题,所以搜索这个“WS28 12”板也会有很多点击。关键的。你运行PIC 18的速度是多少?什么是精确的PIC18F零件号?
以上来自于百度翻译 以下为原文 Now if you had mentioned in the first post that you're talking to a WS2812, you would have got a lot more feedback. There have been a number of topics specifically about talking to that chip, so searching this board for "WS2812" would also have got a number of hits. The timing for those chips is quite critical. What speed are you running your PIC 18 at? What is the precise PIC18F part number? |
|
|
|
我得到了WS28 12工作在一个32兆赫PIC16F1与免费版本的XC8。没有ASM。所以有一个数据点。
以上来自于百度翻译 以下为原文 I got the WS2812 working on a 32mhz pic16f1 with the free version of XC8. No ASM. So there is a data point. |
|
|
|
另外,你可以通过微芯片读到1606年。它解释了如何用内置逻辑单元进行PIC16F1*。
以上来自于百度翻译 以下为原文 Also, you can read AN1606 by Microchip. It explains how to do it with PIC16F1* with built-in logic cells. |
|
|
|
我已经阅读了大部分的这些线索,也看了应用笔记。我想以移植的ARDUINO代码为基础,比较不同的控制方法,并列出各自的优点和缺点。对我来说,这纯粹是一种心理练习,我是一个电哑的机械工程师。我目前使用18F26K80与一个8MHz晶体和4xPLL为32兆赫。这给出了一个8MHz的指令时钟,它给出了每指令125NS(不理想,但可doobe和不太宽容的开销),我可能会尝试内部的RC 16MHz与4xPLL在64兆赫。从我读到的文章中,我链接。时间并不像大多数人认为的那么重要,更重要的因素是比特发送的可靠时间。
以上来自于百度翻译 以下为原文 I have read most of those threads and also looked at the application note. I wanted to start with the ported arduino code as a base and compare the different approaches of control and make a list of pros and cons of each. This is purely a mental exercise for me, I'm an electrically dumb mechanical engineer. I am currently using an 18F26K80 with a 8MHz Crystal and 4xPLL for 32MHz. This gives an instruction clock of 8Mhz which gives 125ns per instruction (not ideal but dooable and not much tolerance for overhead) I might try the internal RC 16Mhz with the 4xPLL at 64Mhz . From what I read in the article that I linked. The timing isn't as critical as most think, the more important factor is reliable timing of the bit sending. |
|
|
|
目前我正在使用以下函数在64兆赫。它在字符串中使用8。我需要订购一根长绳,还要进一步检查是否有毛病。但现在我需要奖励自己一些乐趣。
以上来自于百度翻译 以下为原文 For the time being I am using the following function at 64MHz. It works with 8 in a string. I need to order a long string and further test for glitching. But for now I need to reward myself with some fun. inline void sendBit( bool bitVal ) { if ( bitVal ) { // 0 bit LATBbits.LATB4 = 1; _delay(14); LATBbits.LATB4 = 0; _delay(10); } else { // 1 bit LATBbits.LATB4 = 1; _delay(6); LATBbits.LATB4 = 0; _delay(14); } |
|
|
|
在这一点上,我应该开始一个新的线程,但是我正在为PIC设备制作一个库,因为我教自己如何制作图案和更有趣的效果。我的最新是淡入淡出,非常小的颜色偏移。
以上来自于百度翻译 以下为原文 I should probably start a new thread at this point, but I am making a library for pic devices as I teach myself how to make patterns and more interesting effects. My latest is a fade in fade out with very minimal color shift. |
|
|
|
只有小组成员才能发言,加入小组>>
5166 浏览 9 评论
2000 浏览 8 评论
1929 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3175 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2227 浏览 5 评论
736浏览 1评论
619浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
507浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
633浏览 0评论
530浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-25 03:42 , Processed in 1.511600 second(s), Total 68, Slave 62 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号