parallel slave port in pic16f877 / usrt with pic16f87x

Hello everyone,

I'm trying to design a circuit with pic16f877 with parallel slave port and this is the design I have :

[img]https://www.electro-tech-online.com/attachments/untitled-jpg.115594/[/img]

and this is the C code for this circuit :

/****************************************
*Description :
* SWITCH X6 - /CS
* SWITCH X5 - /WR
* SWITCH X4 - /RD
*****************************************/

/* This header file declares the internal
register addresses for PIC16F874 */
#include <io16f877.h>
// Main
void main(void)
{
unsigned char temp;
ADCON1 = 0x0f; // Configure PORTE pins as digital input
// Define directions for port pins
TRISE = 0x17;
TRISB = 0x00;
do{
if (IBF) temp = PORTD;
else if (OBF == 0) PORTB = temp;
}while(1);
}



I want to add a light sensor with the high priority in this circuit so when the light is more than a specified value,reading and writing stop working.
and altough I have another circuit with pic16f877 :

[img]https://www.electro-tech-online.com/attachments/untitled1-png.115595/[/img]

with this C code :

#include <io16f874.h>
// Transmit
void TXD(unsigned char data)
{
RC2 = 1;
TXREG = data; // Put data into buffer sneds the data
TXEN = 1;
while(!TRMT); // Wait for empty transmit buffer
TXEN = 0;
RC2 = 0;
}
// Receive
unsigned char RXD(void)
{
unsigned char data;
RC0 = 1;
RC0 = 0;
RC0 = 1;
RC1 = 0;
RCIF = 0;
SREN = 1;
TXEN = 1;
while(!RCIF); // Wait for data to be received
data = RCREG; // Read RCREG into data
RC1 = 1;
TXEN = 0;
return(data); // Return received data
}
// Main
void main(void)
{
unsigned char data;
// Set baud rate(19200[bps])
SPBRG = 191;
TXSTA = 0x90;
TRISC = 0xf8; // Set RC<0:2) as outputs
TRISA = 0xff; // Set RA0 input
ADCON1 = 0x06; // Configure all pins as digital inputs
PORTC = 0xfa;
RCSTA = 0x80;
do{
while(RA0);
data = RXD();
TXD(data);
while(!RA0);
}while(1);
}


when we press X4 the value of dip switch will be display on level meter. I want to add a light sensor in this circuit so when the light is more than a specified value, the circuit stop functioning.
can anyone help me with these two problems??

Auto Power off in PIC if gets Idle for some time interval

How to Program pic to make it auto Power off if it gets idle for some time period. like we see in calculators. when we let calculators idle for some time so then it shutdown automatically. I want to program this auto power off in Pic. Please Help

PIC10F200 - Software UART

I would like to write a software transmitter UART for the PIC10F200, the only problem is: It doesn't have a timer overflow interrupt. I don't know how i could manage that every pin toggle takes exactly the same time. My current approach looks like this: [code]#include <p10f200.inc> __CONFIG _WDTE_OFF & _CP_OFF & _MCLRE_ON tmp1 EQU 10h tmp2 EQU 11h org 0x00 movlw 0FFh movwf GPIO movlw 00h tris 6 main movlw 0A5h movwf tmp1 movlw 08h movwf tmp2 bcf GPIO,1 ;Start bit call TransmitByte bsf GPIO,1 ;Stop bit goto main TransmitByte: sr rlf tmp1,f ;shift tmp1 to the left (affects carry bit) btfss STATUS,C ;check carry bcf GPIO,1 ;turn pin to '0' if carry = '0' btfsc STATUS,C bsf GPIO,1 ;turn pin to '1' if carry = '1' decfsz tmp2 ;decrement loop variable goto sr retlw 0 END[/code] This code above looks like this:

https://picload.org/image...pdr/uart_pic10f200.png

Pickit3: EEPROM erased while reading device

Hello all,
PIC16F887
I've made this test:
1)Program some EEPROM cells with fixed values, inside my program, and delete this portion of code
2)In the same program, read EEPROM cells: if values match with programmed ones, blink led
Ok, it works: even if I reprogam (preserving EEPROM), the LED blinks.
3)Read device memory

4)Led stops blinking

Any idea?
Thank you very much.

Using Wi-Fi demo boards with MLA

Has anyone had success in using the Wi-Fi demo boards (DV102411/DV102412) with the Microchip Libraries for Applications?

Looking for a good switch

I know this is a little off topic for this forum, but wanted to throw it out there anyway. I am looking for a small surface mount momentary switch (like a tactile switch) that is a SPDT or DPDT variety. I am making a development board for the PIC32MZ chips, and want to have an on board switch for debugging use. Does anyone know of any examples I could look at? I have found plenty of SPST, but that will not achieve that software feature I need it for.

Any help would be appreciated!

PIC10F202 to PIC10F204

Need little help. Possible this small timer program run in PIC10F204 ? (Currently, I have only 10F204)
Thanks,

(PIC10F202 Flash memory 512, - PIC10F204 256)
------------------------------------------------------------------
Code:

list p=10F202
#include <P10F202.INC>

__config _CP_ON & _MCLRE_OFF & _WDT_OFF

byt1 equ .16 ;
byt2 equ .17 ;
byt3 equ .18 ;
ORG 0x0000 ; reset vektor
init

MOVWF OSCCAL
MOVLW 0xE
TRIS .6
MOVLW b'11111000'
OPTION
CLRF GPIO
CLRF TMR0
mx7
MOVF TMR0, W
BTFSS STATUS,Z
GOTO mxc
BCF GPIO, 0
GOTO mx7
mxc
DECF TMR0, F
BSF GPIO, 0
CALL mx10
GOTO mx7
mx10
MOVLW .7
MOVWF byt1
MOVLW 0x2f
MOVWF byt2
MOVLW .3
MOVWF byt3
mx16
DECFSZ byt1, F
GOTO mx19
DECFSZ byt2, F
mx19
GOTO mx1b
DECFSZ byt3, F
mx1b
GOTO mx16
NOP
NOP
NOP
RETLW 0

END

How to print the Omega symbol using sprintf?

Hi,
I have this code that works OK.
==============================================
char cstr[40];
sprintf(cstr, "Contact Resistance : %d, ", contact_resistance); //format string
write_lcd_line4(cstr, 1); //Write to LCD
===================================================

It displays "Contact Resistance: 12345".
I would like to print " Contact Resistance: 12345 <OMEGA symbol>"
I am using MPLAB X.
Any idea please?

PIC I/O For Simpleminds

Developers

Can I get a starting point with this?

Been reading section in datasheet of PIC16F54 about pins.

Just looking for sort of general explanation about this.

Thanks.

XC8 Table Array Workaround for PIC18FXXK40, Slicon Rev A3

Hello All,

Like many of you I ran into errata DS80000712B. Adding +NVMREG in the errata field in the linker properties did not change the symptom for me. I found other threads on the forum with the same result. Adding powerup.as worked for me, as it did for others. One thing to be careful of is that the syntax and formatting of the .as file is exact. The code should look like the attached photo. Make sure that you do not have any extraneous blank lines after the "end" keyword on line 9. Blank lines after end will give you a preprocessor syntax error which is blank.

To make it easier I've also attached a working powerup.as file. Just add this file to your project as a Source file. One more thing, if you use arrays in EEPROM the NVMREG bits will be changed.
Syed Zain Nasir

I am Syed Zain Nasir, the founder of <a href=https://www.TheEngineeringProjects.com/>The Engineering Projects</a> (TEP). I am a programmer since 2009 before that I just search things, make small projects and now I am sharing my knowledge through this platform.I also work as a freelancer and did many projects related to programming and electrical circuitry. <a href=https://plus.google.com/+SyedZainNasir/>My Google Profile+</a>

Share
Published by
Syed Zain Nasir