pic

Why is Timer1 not counting up on PIC18?

允我心安 提交于 2019-12-13 04:38:03
问题 Initially I had Timer0 working fine during the run mode. The only problem is when the device goes to sleep mode, Timer0 stops counting up until awaken. In the datasheet it says to use Timer1 to be able to monitor time during sleep mode. I modified timer0 existing code to timer1 new configurations, the other code is pretty much the same. However, there is something I might have missed that is different about timer1 than timer0, since the timer1 is not counting up at all. The PIC I'm using is

Adding with carry on PIC16 (or similar)

假装没事ソ 提交于 2019-12-13 00:55:15
问题 There is no "add with carry" instruction on PIC 16. But what if I had to add larger data quantity than just a byte? All the Web resources and Microchip application notes I've found suggest something like: MOVF LSB_A, w ADDWF LSB_B MOVF MSB_A, w BTFSC STATUS, C INCFSZ MSB_A, w ADDWF MSB_B but the code above will just not work. I mean the 16-bit result will be correct, but the carry won't be set properly, so you can't just expand the computational range by repeating the second part of the code

How can I write hardware independent functions in C for the PIC24

烂漫一生 提交于 2019-12-12 20:09:10
问题 I am working on some code that impliments various features such as a PID controller, signal generator, etc. My hardware provides various inputs and outputs. Just now I have a load of SWITCH statement to determine the source and destination of my calculations. For example for the PID controller, there is a switch command every 100ms that decides which input to pass to the pid_calculate function, followed by another switch to decide what to do with the return value. As I have 32 analog inputs,

使用python爬虫爬取自定网址的图片,并下载到自定文件夹

早过忘川 提交于 2019-12-12 18:21:22
# encoding=gbk import re import urllib import os import requests def get_onepage_urls(onepageurl): if not onepageurl: print('执行结束') return [], '' try: html = requests.get(onepageurl).text except Exception as e: print(e) pic_urls = [] fanye_url = '' return pic_urls, fanye_url pic_urls = re.findall('"objURL":"(.*?)",', html, re.S) html = requests.get(onepageurl) html.encoding = 'utf-8' content = html.text fanye_urls = re.findall(re.compile(r'<a href="(.*)" class="n">下一页</a>'), content, flags=0) fanye_url = 'http://image.baidu.com' + fanye_urls[0] if fanye_urls else '' return pic_urls, fanye_url

PIC16F883 Led Blink

本秂侑毒 提交于 2019-12-12 16:07:27
问题 I need to program a PIC16F883 to blink / light up LED's at the same time. The oscillator is running at 3,2768, and I'm using TIMER0 to help me with the timing. Right now, I have a prescaler set to 1:256, so I get an interrupt every 50ms, and I have a variable that is calculated from that, to display how many seconds has gone. If the input is changed, the seconds variable is of course reset again. Here is the assignment from my teacher: If Input is 0 (Closed): The Red And The Green LED should

Writing to EEPROM on PIC

别说谁变了你拦得住时间么 提交于 2019-12-12 15:10:34
问题 Are there any PIC microcontroller programmers here? I'm learning some PIC microcontroller programming using a pickit2 and the 16F690 chip that came with it. I'm working through trying out the various facilities at the moment. I can sucessfully read a byte from the EEPROM in code if I set the EEPROM vaklue in MPLAB but I don't seem to be able to modify the value using the PIC itsself. Simply nothing happens and I don't read back the modified value, I always get the original which implies to me

Unable to send continuous data on Thingspeak using SIM800L

天涯浪子 提交于 2019-12-11 19:37:02
问题 I am trying to send data on thingspeak using TCP/IP connection with SIM800L and PIC16F1936. But it is not sending data to thingspeak meanwhile the ADC value is getting changed with change in analog input. I am unable to find what I am missing. #include "mcc_generated_files/mcc.h" #include <string.h> #include <stdlib.h> #include <stdio.h> #include <stdbool.h> #define _XTAL_FREQ 16000000 #define RS RB0 #define RW RB1 #define EN RB2 char buff[80], a; char data[80]; int flag, b, i = 0; int adc

Kiss FFT on a dsPIC33

与世无争的帅哥 提交于 2019-12-11 16:34:56
问题 I have been trying to get KissFFT to work on a dsPIC, however after trying various different ways, the output is not what it should be. I was hoping to get some help to see if there are any configurations that I may be overlooking or if its just somthing i haven't thought of? I am using a dsPIC33EP256MC202 with the XC16 compiler within MPLABX. Declarations and memory assignment. int readings[3] = {0, 0, 0}; kiss_fft_scalar zero; memset(&zero,0,sizeof(zero)); int size = 128 * 2; float fin[256]

MpLab Link Error: Could Not Allocate Section (C30 Compiler)

↘锁芯ラ 提交于 2019-12-11 15:11:44
问题 I have put the two pieces of code together (originally described in This Question Here). I have now just experienced this error from MpLab (Microchip MPLAB C30) Link Error: Could not allocate section .nbss, size = 20004 bytes, attributes = bss near Strangest thing, I looked for that message, even sub-strings of that message, in the Compiler manual (Microchip publication DS51284F) and found nothing. I even looked for the single word allocate and found it only three or four times, never with an

PIC Microcontrollers: Scan inputs on a 4x4 Keypad, using only Port C RC0-RC3 in C

淺唱寂寞╮ 提交于 2019-12-11 11:06:10
问题 I'm new to PIC Microcontrollers & C programming and I've been set the task of creating my own Keypad scanning method that works exclusively on Port C (16F877A Microcontroller). Specifically, the program that uses this method only uses digits 1, 2, 4 and 5- so to be efficient, the scanner method is to only use RC0, RC1, RC2 and RC3 as the designated input/ outputs (I'm not allowed to use RC4-RC7). This essentially turns the 4x4 keypad into a 2x2 keypad. I understand that the concept on