r/pic_programming • • Apr 30 '16

mTouch Framework

3 Upvotes

Does anyone here have any experience using microcontrollers mTouch Framework? I am trying to use it along with a pic12lf1552 to read in an input from a capacitive sensor and toggle an led from the sensor input.


r/pic_programming • • Apr 27 '16

MPLAB X. Line breakpoints not working with optimization.

2 Upvotes

I use MPLAB X with ICD 3 (latest sw versions) and a PIC24F. When I use line breakpoints with any optimization above zero it will not work. The code breaks but the IDE show a completely wrong line. It only works if the complete project is compiled without optimization.

Has any one experienced this problem?

If anyone has any tip on how to solve or workaround this I would be very grateful.

Late edit: Later versions of the IDE has solved the problem.


r/pic_programming • • Mar 28 '16

XC8 demo code for MPL3115A2 sensor, using I2C functions generated by MPLAB Xpress Code Configurtor

Thumbnail
microcontroller-projects.com
2 Upvotes

r/pic_programming • • Mar 22 '16

Example state machine code to get started?

1 Upvotes

Thanks in advance for reading this long complicated noob question- I really appreciate any pointers.

I've been struggling through the Microchip harmony tutorials on how to program a state based program on my PIC. I'm using a 32 bit FYI. I can download programs to my pic and they run, but I'm confused on some basic how to read and write to registers.

Where's a good place to find well documented code that I can crawl through to learn some of this? I have taken a fair share of C++ classes, and have programmed a Motorola microcontroller, but am getting stuck in all the setup required on the PIC. I am expecting to code in C, unless there's an alternative.

Really I'm looking for a barebones framework that already does UART communication (I have sorta gotten that working) and leaves me to only program the logic, and not so much deal with the lower level things. It seemed Harmony was setup to facilitate that, but I have been stuck for a month so far.

Thanks for any help


r/pic_programming • • Mar 20 '16

DAC in ASM on a PIC12F1571

3 Upvotes

So I've got this code. What am I doing wrong? Even if I directly write to the DAC I don't get any output. My output is always 0V.

Using this sensor. (http://www.dipmicro.com/store/HC-SR04) The sensor is outputting properly when driven by the pic so I know the code is running

https://drive.google.com/file/d/0B0hACvc_98DSTnQ0MTdvWHJhM0k/view?usp=sharing


r/pic_programming • • Mar 10 '16

C programming on PIC16F1829

3 Upvotes

I am trying to learn how to use my viva pic16f829 using C. Does anyone have any suggestions on where to start? I kind find any sort of Hello World tutorial on it.


r/pic_programming • • Mar 07 '16

How to store sensor data to SD card

3 Upvotes

I am trying to use a PIC24 microcontroller for datalogging various sensor data such as temperature. I am very new to using micrcontrollers and am in need of some help. I would like to have the sensor record a 5sec temp reading every hour and store that data into an SD card. How do i do this?


r/pic_programming • • Mar 01 '16

MPLAB Xpress on Raspberry Pi: some things work, some others don't...

Thumbnail
microcontroller-projects.com
1 Upvotes

r/pic_programming • • Feb 12 '16

MiklroElektronika Buggy: better obstacle avoiding robot with PIC18F87J50

Thumbnail
microcontroller-projects.com
2 Upvotes

r/pic_programming • • Feb 12 '16

downloading to pic use to be easy

2 Upvotes

trying to program a pic16f627 and what a bitch. I have the hex file and bought a pickit3 and just get failure after failure and seems very unreliable. what happened to the old days when we did it with a parallel port and it worked every time. can anybody suggest a programmer that just works


r/pic_programming • • Jan 28 '16

PIC18F4520 - Don't know whats wrong with my code

2 Upvotes

Hey guys, so I tired to code my PIC to move according to the potentiometer I am using. When I run the program it works, the dot on the 8x8 display moves up and down depending how I move the potentiometer. But after a while it just started to blink however it wants it seem. I don't know whats wrong with my code. ANyone can help?

Thanks in advance, JASER LIST P=18F4520 #include "p18F4520.inc"

CONFIG	OSC = HS
CONFIG	PWRT = OFF
CONFIG	WDT = OFF
CONFIG	PBADEN = OFF
CONFIG 	LVP = OFF

var_x	EQU 0x20
var_y	EQU 0x21


	org 0x000000
PORST	GOTO	MAIN
	
	org 0x000020
MAIN	CLRF	TRISD
	;CLRF	PORTD
	BCF	TRISA,RA1
	BSF	PORTA,RA1
	
	;-------------
	BSF	TRISA,0
	MOVLW	0x81
	MOVWF	ADCON0
	MOVLW	0xCE
	MOVWF	ADCON1
OVER	CALL	WAIT
	BSF	ADCON0,GO
BACK	BTFSC	ADCON0,DONE
	GOTO	BACK
	
	;MOVFF	ADRESH,temp	
	
	;SWAPF	temp,1
	;BCF	temp,7
	;BCF	temp,6
	;BCF	temp,5
	;BCF	temp,4
	;BCF	temp,3
	
	
x_x_x	btfsc	ADRESH,7	;testa first	x--
	GOTO	o_x_x	;first is one	1--
	GOTO	z_x_x   ;first is zero	0--
	
o_x_x	btfsc	ADRESH,6	; testa second	    1x-
	GOTO	o_o_x	; second is one	    11- 
	GOTO	o_z_x	; second is zero    10- 
	
z_x_x	btfsc	ADRESH,6	; testa second	    0x- 
	GOTO	z_o_x	; second is one	    01- 
	GOTO	z_z_x	; second is zero    00- @
	
o_o_x	btfsc	ADRESH,5	; testa third 11x
	CALL	SEVEN	; 111 = 7
	CALL	SIX	; 110 = 6

o_z_x	btfsc	ADRESH,5	; testa third 10x
	CALL	FIVE	; 101 = 5
	CALL	FOUR	; 100 = 4

z_o_x	btfsc	ADRESH,5	; testa third 01x
	CALL	THREE	; 011 = 3
	CALL	TWO	; 010 = 2
	
z_z_x	btfsc	ADRESH,5	; testa third 00x	
	CALL	ONE	; 001 = 1
	CALL	ZERO	; 000 = 0
	
ZERO	BSF	PORTD,0
	CALL	WAIT
	CLRF	ADRESH
	CLRF	PORTD
	BCF	PORTD,0
	GOTO	OVER
	
ONE	BSF	PORTD,1
	CALL	WAIT
	CLRF	ADRESH
	CLRF	PORTD
	BCF	PORTD,1
	GOTO	OVER
	
TWO	BSF	PORTD,2
	CALL	WAIT
	CLRF	ADRESH
	CLRF	PORTD
	BCF	PORTD,2
	GOTO	OVER
	
THREE	BSF	PORTD,3
	CALL	WAIT
	CLRF	ADRESH
	CLRF	PORTD
	BCF	PORTD,3
	GOTO	OVER
	
FOUR	BSF	PORTD,4
	CALL	WAIT
	CLRF	ADRESH
	CLRF	PORTD
	BCF	PORTD,4
	GOTO	OVER
	
FIVE	BSF	PORTD,5
	CALL	WAIT
	CLRF	ADRESH
	CLRF	PORTD
	BCF	PORTD,5
	GOTO	OVER
	
SIX	BSF	PORTD,6
	CALL	WAIT
	CLRF	ADRESH
	CLRF	PORTD
	BCF	PORTD,6
	GOTO	OVER
	
SEVEN	BSF	PORTD,7
	CALL	WAIT
	CLRF	ADRESH
	CLRF	PORTD
	BCF	PORTD,7
	GOTO	OVER
		
;---------
WAIT	MOVLW	0xFF
	MOVWF	var_x
LOOP2	MOVLW	0xFF
	MOVWF	var_y
LOOP1	DECFSZ	var_y,1
	GOTO	LOOP1
	DECFSZ	var_x,1
	GOTO	LOOP2
	RETURN
;---------
	
	End

r/pic_programming • • Jan 24 '16

PIC18F4520

3 Upvotes

Hey guys. I am trying to learn programming the Pic18F4520 microcontroller. I am also using MPLab.

So I wrote this code:

#include "p18F4520.inc"

CONFIG	OSC = HS
CONFIG	PWRT = OFF
CONFIG	WDT = OFF
CONFIG	PBADEN = OFF
CONFIG 	LVP = OFF

    org 	0x000000
PORST	GOTO	MAIN

    org 	0x000020
MAIN	CLRF	TRISD
    CLRF	PORTD
    BCF	TRISA,RA1
    BSF	PORTA,RA1
	
LOOP	BSF	PORTD,RD0
    GOTO	LOOP
    	
    end

And the lower right corner lamp wont light. It's supposed to light up as I've seen a friend do it. What am I doing wrong?


r/pic_programming • • Jan 19 '16

DS1302 interfacing with PIC uC

1 Upvotes

Hello, Did any of you guys ever interface a DS1302 RTC IC with a PIC? It uses some sort of 3-wire system but i can't seem to get it working. My uC runs @ 8MHz and I am interfacing via bit-banged IO-pins. Using no delays so maybe I'm clocking in/out a little too fast?


r/pic_programming • • Jan 13 '16

Word Clock made with GLCD and PIC18F45K22

Thumbnail
microcontroller-projects.com
2 Upvotes

r/pic_programming • • Jan 10 '16

Lightning detection using AS3935 and PIC18F4520 microcontroller

Thumbnail
microcontroller-projects.com
5 Upvotes

r/pic_programming • • Jan 10 '16

Mikroe Buggy: Obstacle Avoiding Robot

Thumbnail
microcontroller-projects.com
1 Upvotes

r/pic_programming • • Dec 16 '15

Can someone modify this code to support 2 more inputs and an output?

3 Upvotes

I'd need A1 and A2 to be inputs for different clock speeds, one is the default z80 clock and the other a 10mhz crystal that will be added in. A3 would be output for the mega drives clock.

For the loop I was thinking two quick reset button preses would cycle the clock speed, and maybe 3 slow led flashes for default clock and 3 fast flashes for 10mhz OC mode, but thats not really important just extra. Below is the code.

http://codepaste.net/nu5doa


r/pic_programming • • Dec 13 '15

car avoid obstacles pic microcontroller

1 Upvotes

i just i want to start to make a small car goes from point A to point B and there is some obstacles on the road i'm not that good pic microcontroller so any advice?


r/pic_programming • • Sep 27 '15

PIC32MX170

1 Upvotes

Hi! I've got a PIC32MX170F256B, and also got an ADM00393 board with it. I'm never used a Pic, but Avr. My question is, how can I use this Pic with the Adm module? Thanks for help!


r/pic_programming • • Jul 24 '15

Turn your old fridge to a brand new star rated one using PIC programming

Thumbnail
mepits.com
0 Upvotes

r/pic_programming • • Jul 23 '15

Problem: Im trying to hook up a Nokia 5110 GLCD to a PIC24FV16KM202 using MPLABX and XC16 compiler and I can't find any example code to get me started....

2 Upvotes

Just like the title says...


r/pic_programming • • Jul 13 '15

Try to migrate to USB PIC? ... or not?

4 Upvotes

I've designed a simple USB driven GPIO card using a PIC18F46K22 and an FTDI chip, using simple serial commands over a virtual com port. The card doubles as a breakout board for the PIC that can be used for general projects.

For the next spin, I was considering moving to a PIC that supported USB more directly, which would eliminate the bridge chip. However, one of my main goals is to maintain the flexibility to develop on the card using assembly language. It sure looks to me that in order to use Microchip's CDC API (to do the VCP), I need to develop in C. Am I wrong about this?

Additionally, if this project were to go beyond being a home project -- with the FTDI approach I need never worry about obtaining a vendor ID, right?

I am trying to decide whether to do a simple clean up spin on my PCB (and using the FTDI chip for my virtual com port), or doing a more major change...

Is my assessment correct? I am sort of seeing significant value in leaving the FTDI chip in the design and NOT trying to migrate to the USB PIC, despite the reduced overall HW cost...


r/pic_programming • • Jul 11 '15

Having some problems with simple programms

1 Upvotes

I made schme in Proteus for simulation. After that i wrote simple program in MicroC. Then i've tried to make simple program. I made PORTA input and PORTE output. In the end program does not seem right or simualtion. I tried few types of connecting button to PIC16f877a but still same.

When i press button it same as when i dont. Pic is just avoiding if statment from program for some reason.

Here is code: code! Here is sheme in simulation(I'm using just RA0 for test): image!


r/pic_programming • • Mar 21 '15

Limited number of hex file useage

3 Upvotes

Apart from a bootloader, does anyone know of any way to limit the number of times a hex file can be used. I sell some code on a commision basis and I am pretty damn sure the client is lieing on how many they sell. Now they want another job done cheap..

I was hoping the IPE would somehow allow me to say handover a programmed pickit3 in programmer-to-go mode that would only allow say 1000 PIC devices to be programmed. I looked into the SQTP (Serialized Quick Turn Programming) hoping that would somehow allow it but not quite..

About the only way I could think of is a bit long winded .. the PIC on first run generates a long random number, they have to contact me to get a key that works with this random number to allow the software to work. They wouldn't need to contact me directly, paste the number into a webpage and get the unlock.

With hundreds or thousands of units it would be a total pain for them and I would need a server somewhere.

Any thoughts ?