mplab

How can I exit my lookup table instruction with the desired value on PIC16F1829

不想你离开。 提交于 2021-01-29 08:19:34
问题 How can I get my code to work correctly when I include ADC conversion in it? I have a working code that displays two digits on 2 LED displays using a p16f1829. However, a problem arises when I try to include a code block that collects the results of an ADC conversion to display on the LED display (see below). A2D: ; Start the ADC NOP ; Requried ADC delay of 8uS => (1/(Fosc/4)) = (1/(500KHz/4)) = 8uS BANKSEL ADCON0 ; Selects memory bank containing ADCON0 register BSF ADCON0, GO ; Start the ADC

Reading state of input pins on a PIC18

我怕爱的太早我们不能终老 提交于 2020-01-02 09:44:47
问题 I have been able to get outputs working on my PIC and can make a bunch of LEDs dance on and off as I set various output latches high/low. However, I'm having a lot o difficulty reading in the state of a pin. See the code below. I set up my config, and define the TRISC as input and TRISB as output. In an infinite loop, I check to see whether RC6 is high or low, and set the entire B latch high or low depending on the result. #include <htc.h> __CONFIG(1, FOSC_IRC & FCMEN_OFF & IESO_OFF); _

Reading state of input pins on a PIC18

南楼画角 提交于 2020-01-02 09:43:32
问题 I have been able to get outputs working on my PIC and can make a bunch of LEDs dance on and off as I set various output latches high/low. However, I'm having a lot o difficulty reading in the state of a pin. See the code below. I set up my config, and define the TRISC as input and TRISB as output. In an infinite loop, I check to see whether RC6 is high or low, and set the entire B latch high or low depending on the result. #include <htc.h> __CONFIG(1, FOSC_IRC & FCMEN_OFF & IESO_OFF); _

Set Output Port High Low C

瘦欲@ 提交于 2020-01-01 19:47:39
问题 I'm using MPLAB to compile a program in C using the CCS compiler. I want to set an output port as high or low using defined ports. #bit portOut1 = PORTC.0 So, I want to set my portOut1 high or low. I had used 3 ways to do it, but just one had worked. But I'm not satisfied with that. 1: (Doesn't work, why?) portOut1 = output5.value; 2: (Doesn't work, why?) output_bit(portOut1,value); 3: (Obviously work) output_bit(pin_c0, value); I don't understand why the first and second way doesn't work.

Set Output Port High Low C

谁说胖子不能爱 提交于 2020-01-01 19:47:28
问题 I'm using MPLAB to compile a program in C using the CCS compiler. I want to set an output port as high or low using defined ports. #bit portOut1 = PORTC.0 So, I want to set my portOut1 high or low. I had used 3 ways to do it, but just one had worked. But I'm not satisfied with that. 1: (Doesn't work, why?) portOut1 = output5.value; 2: (Doesn't work, why?) output_bit(portOut1,value); 3: (Obviously work) output_bit(pin_c0, value); I don't understand why the first and second way doesn't work.

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

No source code lines were found at current PC 0x0

旧巷老猫 提交于 2019-12-13 18:05:41
问题 I am having issues using MPLAB X IDE. I have a main.c with a main section. When I try to debug, I can't. It says no source code lines were found. I have compiled the software and debugged in MPLAB IDE without issue. I feel as though there is a setting in MPLAB X or something else basic that I am missing. Though I am not sure it is useful, for the sake of information, I am using a PICKit2 for debugging, MPLAB X IDE v1.51, PIC16F876 uC. main code in main.c: int main(int argc, char** argv) {

How to store values in an array to a variable on MPLAB?

时光怂恿深爱的人放手 提交于 2019-12-13 06:22:23
问题 The following code works fine on CodeBlocks compiler but on MPLAB C18 compiler I don't get the same results. I am using PIC18 microcontroller. Code int d[6]; int all; d[0] = 6; d[1] = 4; d[2] = 8; d[3] = 0; d[4] = 0; all = 10000*d[0] + 1000*d[1] + 100*d[2] + 10*d[3] + d[4]; printf("%d", all); Output on CodeBlocks : 64800 Output on MPLAB : -816 What is exactly the problem? Shouldn't this code work fine? Thanks! 回答1: Objects that have the type int aren't guaranteed to be able to store values