Чт фев 03, 2022 05:03:54
Вт фев 15, 2022 15:44:53
Вт фев 15, 2022 16:35:12
KLINE_OUT = 1; // start bit
uint8_t out_data = *ptr++;
for (uint8_t j = 0; j < 8; j++)
{
while (!PIR1bits.TMR2IF) {}
PIR1bits.TMR2IF = 0;
if ((out_data & 0x01) != 0)
{
KLINE_OUT = 0;
}
else
{
KLINE_OUT = 1;
}
out_data >>= 1;
}
Пт фев 18, 2022 19:59:38
Пт фев 18, 2022 20:20:20
Пт фев 18, 2022 21:12:10
Пт фев 18, 2022 22:19:50
Зачем ? У вас уже реализовано прерывание, пользуйтесь им.cxem писал(а):И функция while (1) должна его выталкивать постоянно
Пт мар 25, 2022 14:46:52
В самом начале было сделано так:
void wakeup ()
{
TRISA = 0b00111111; //PortA input RA0...RA5
TRISB = 0b00000000; //TRISB = 0 portB output
TRISC = 0b11111110; //TRISC turn RC0 output
TRISD = 0b00000011; //TRISD make D2..D7 outputs,D2=sck,D1=inpLost
TRISE = 0b00000111; //TRISE = 1 portE inputs, PSP=0 RD in GP mode
ADCON0 = 0b00000000; // RA0..RA5 are digital inputs
ADCON1 = 0b00000111; // RA0..RA5 are not analog
PORTA = 0;
PORTB = 0;
PORTC = 0;
PORTD = 0;
PORTE = 0;
RBPU = 0; // RB pull-up on
lcd_init();
lcd_clear();
};
Текст lcd.c (в комментариях то, что было до изменений):
/*
* LCD interface example
* Uses routines from delay.c
* This code will interface to a standard LCD controller
* like the Hitachi HD44780. It uses it in 4 bit mode, with
* the hardware connected as follows (the standard 14 pin
* LCD connector is used):
*
* PORTD bits 0-3 are connected to the LCD data bits 4-7 (high nibble)
* PORTA bit 3 is connected to the LCD RS input (register select)
* PORTA bit 1 is connected to the LCD EN bit (enable)
*
* (это мною уже добавлено)
* LCD is BOLYMIN BC2004.
* To use these routines, set up the port I/O (TRISD!) then
* as it described earlier!
* This project don't use PORTA for LCD management.
*
*/
#include <pic.h>
#include "lcd.h"
#include "delay.h"
#define LCD_RS RD2 //rem was LCD_RS RA3
//#define LCD_RW RA2 //rem RW allways 0
#define LCD_EN RD3 //rem LCD_EN RA1
#define LCD_DATA PORTD
#define LCD_STROBE() ((LCD_EN = 1),(LCD_EN=0))
/* write a byte to the LCD in 4 bit mode */
void
lcd_write(unsigned char c)
{
DelayUs(40);
LCD_DATA = ( ( c >> 4 ) & 0x0F );
LCD_STROBE();
LCD_DATA = ( c & 0x0F );
LCD_STROBE();
}
/* Clear and home the LCD */
void
lcd_clear(void)
{
LCD_RS = 0;
lcd_write(0x1);
DelayMs(2);
}
/* write a string of chars to the LCD */
void
lcd_puts(const char * s)
{
LCD_RS = 1; // write characters
while(*s)
lcd_write(*s++);
}
/* write one character to the LCD */
void
lcd_putch(char c)
{
LCD_RS = 1; // write characters
lcd_write( c );
}
/* Go to the specified position */
void
lcd_goto(unsigned char pos)
{
LCD_RS = 0;
lcd_write(0x80+pos);
}
/* initialise the LCD - put into 4 bit mode */
void
lcd_init()
{
char init_value;
//ADCON1 = 0x06; //Disable analog pins on PORTA. (ADCON1 now not used!)
init_value = 0x3;
//TRISA=0; //rem in original was this
TRISD=0b00000011; //Checked, RD0,RD1 are inputs - don't touch them!
LCD_RS = 0;
LCD_EN = 0;
//LCD_RW = 0; //rem RW allways 0
DelayMs(15); // wait 15mSec after power applied,
LCD_DATA = init_value;
LCD_STROBE();
DelayMs(5);
LCD_STROBE();
DelayUs(200);
LCD_STROBE();
DelayUs(200);
LCD_DATA = 2; // Four bit mode
LCD_STROBE();
lcd_write(0x28); // Set interface length
lcd_write(0xF); // Display On, Cursor On, Cursor Blink
lcd_clear(); // Clear screen
lcd_write(0x6); // Set entry Mode
}
Пт мар 25, 2022 16:54:02
Пт мар 25, 2022 17:51:07
Пт мар 25, 2022 19:31:35
Пт мар 25, 2022 19:37:54
Пт мар 25, 2022 20:55:53
Пт мар 25, 2022 21:12:31
Пт мар 25, 2022 22:23:20
Вс мар 27, 2022 09:06:58
#define LCD_STROBE() (LCD_EN = 1, LCD_EN = 0)
Вс мар 27, 2022 13:29:51
Вс мар 27, 2022 14:32:53
Пн мар 28, 2022 08:31:51
Пн мар 28, 2022 08:45:45