pic

Difference between PORT and LATCH on PIC 18F

微笑、不失礼 提交于 2019-12-28 05:14:23
问题 I already read the datasheet and google but I still don't understand something. In my case, I set PIN RC6 of a PIC18F26K20 in INPUT mode: TRISCbits.TRISC6 = 1; Then I read the value with PORT and LATCH and I have different value! v1 = LATCbits.LATC6; v2 = PORTCbits.RC6; v1 gives me 0 where v2 gives 1. Is it normal? In which case we have to use PORT and in which case LATCH? 回答1: The latch is the output latch onto which values are written. The port is the voltage at the actual pin. There are a

py3.6爬取图片

帅比萌擦擦* 提交于 2019-12-28 05:11:20
PY3.6爬取图片,附带断点续传 在这里插入代码片 ``` import urllib . request import bs4 import re import os from urllib import request # 模拟浏览器访问url并获取页面内容(即爬取源码) def getHtml ( url ) : user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" headers = { "User-Agent" : user_agent } request = urllib . request . Request ( url , headers = headers ) response = urllib . request . urlopen ( request ) html = response . read ( ) return html # 爬取整个网页(这里就细致一些,指定编码之类的) def parse ( url ) : html_doc = getHtml ( url ) sp = bs4 . BeautifulSoup ( html_doc ,

Program returns to its main point unexpectedly at Pic C in MPlab

百般思念 提交于 2019-12-25 05:08:51
问题 I'm programming a stepper motor with PIC16F84 in MPlab IDE. My program returns it's starting point after I call it's delay method. To be more spesific, some of code snippets here. main method to drive program int main(int argc, char** argv) { TRISB = 0; // PORT B as output port PORTB = 0x0F; stepForward(25); activateRelay(); waitForSeconds(3000); deActivateRelay(); stepBackward(50); //Since step forward method steps for 100, this will return to initial state stepForward(25); return (EXIT

PIC - is there a value for RB7?

爱⌒轻易说出口 提交于 2019-12-25 04:32:20
问题 I read the port RB7, and in the if a check the value. if there is output on RB7 I want that the led on my chip light up (led D1), but it burns all the time even when there is nothing connected to RB7. What i'm doing wrong? That's the PIC 18F4550 It's written in mplab v8.63 and the C18 compiler. void main (void) { TRISD = 0x00; // PORTD als uitgang TRISB = 0b00110000; // RB4 en RB5 als ingang RCONbits.IPEN = 0; // prioriteit uit INTCONbits.GIE = 1; // enable interrupt INTCONbits.RBIE = 1; //

django中上传图片分页三级联动效果的实现代码 - python

折月煮酒 提交于 2019-12-24 18:12:56
文章来源: 嗨学网 敏而好学论坛www.piaodoo.com 欢迎大家相互学习 Django1.8.2中文文档:Django1.8.2中文文档 上传图片配置上传文件保存目录 1)新建上传文件保存目录。 2)配置上传文件保存目录。 后台管理页面上传图片 1)设计模型类。 2)迁移生成表格。 3) 注册模型类。 后台管理页面上传图片实例 1.在static下面创建media文件夹(再在media文件夹里面新建booktest文件夹)。 2.设置静态文件保存目录 # 设置上传文件的保存目录 MEDIA_ROOT = os.path.join(BASE_DIR, 'static/media') 3.编写图片模型类 class PicTest(models.Model): """上传图片""" goods_pic = models.ImageField(upload_to='booktest') # 指定上传图片到media下面的booktest文件夹下 4.迁移数据 python manage.py makemigrations python manage.py migrate 如果项目用的是原来的数据库,那么应该先去django_migrations里面删除booktest的init文件; delete from django_migrations where id = xxx;

How to erase just some bytes of Flash Memory?

a 夏天 提交于 2019-12-24 05:42:06
问题 My PIC18F87J11 only erases 1024 bytes at a time. Is there away to force it to only erase 2 bytes or more at a time? I am making a Bootloader and sometimes only one line of the HEX file (16 bytes) changes for the application program, so I want to replace that line in memory with the new 16 bytes only . If I try to erase those 16 bytes, automatically 1024 bytes get erased too. Then I am forced to re-write them which takes some time and reduce the speed of the Bootloader. Is there an alternative

How to convert an int to a series of characters

寵の児 提交于 2019-12-24 04:34:04
问题 I'm trying to break down an integer with C on an 8-bit microcontroller (a PIC) into its ASCII equivalent characters. For example: convert 982 to '9','8','2' Everything I've come up with so far seems pretty brute force. This is the main idea of what I'm basically doing right now: if( (10 <= n) && (n < 100) ) { // isolate and update the first order of magnitude digit_0 = (n % 10); // isolate and update the second order of magnitude switch( n - (n % 10) ) { case 0: digit_1 = 0; break; case 10:

PHP中的文件上传

旧时模样 提交于 2019-12-23 03:51:49
文件上传: 1.单个文件上传 2.多个文件上传 一.PHP配置文件中和上传有关的选项 file_uploads=on upload_max_filesize= 最大不要超过服务器的内存 upload_tmp_dir= 上传文件的临时路径 二.上传表单需要注意事项 1.如果有文件操作,表单的提交方式必须是POST提交 2.表单上传需要使用type为file的表单 3.enctype="multipart/form-data"只要有文件上传就要改为这个值,其他情况可以使用默认值,用来指定表单编码的数据方式,让服务器知道,我们需要传递一个文件并带有一些常规的表单信息 4.建议添加一个MAX_FILE_SIZE隐藏表单,值得单位也是字节 三.PHP处理上传的数据 如果是文件上传的数据则使用$_FILES处理上传的文件 $_POST接受非上传的数据 //上传文件传递的信息 Array ( [pic] => Array ( [name] => 1.jpg [type] => image/jpeg [tmp_name] => uploadtemp\phpFFAB.tmp [error] => 0 [size] => 9992 ) 1.使用$_FILES["表单名"]["error"]检查上传是否出错 UPLOAD_ERR_OK 其值为 0,没有错误发生,文件上传成功。 UPLOAD_ERR

How to tell clang that my LLVM Target should use 16-bit 'int'?

天涯浪子 提交于 2019-12-22 17:59:55
问题 For my PIC Backend, I want 'int' to be 16 bits. How can I / my target tell clang what should be the size of 'int'? Defining 16-bit registers only seems not sufficient. Currently "clang -O2 -emit-llvm -target pic" converts int foo(int a, int b) { return a + b; } to this IR code, using 32-bit integers: ; ModuleID = '../test/sum.c' source_filename = "../test/sum.c" target datalayout = "e-m:e-p:16:16-i16:16-a:0:16-n16-S16" target triple = "pic" ; Function Attrs: norecurse nounwind readnone define

Remake of Fletcher checksum from 32bit to 8

拜拜、爱过 提交于 2019-12-22 12:36:41
问题 Is this conversion right from the original? uint8_t fletcher8( uint8_t *data, uint8_t len ) { uint8_t sum1 = 0xff, sum2 = 0xff; while (len) { unsigned tlen = len > 360 ? 360 : len; len -= tlen; do { sum1 += *data++; sum2 += sum1; tlen -= sizeof( uint8_t ); } while (tlen); sum1 = (sum1 & 0xff) + (sum1 >> 4); sum2 = (sum2 & 0xff) + (sum2 >> 4); } /* Second reduction step to reduce sums to 4 bits */ sum1 = (sum1 & 0xff) + (sum1 >> 4); sum2 = (sum2 & 0xff) + (sum2 >> 4); return sum2 << 4 | sum1;