Serial communication with uC.
in
Integration and Hardware
•
3 months ago
Hi,
I am suing processing 1.5 with XP 32bit and i want to do serial comm of uC using PIC16F877 with processing and tested that pic uC code in serial terminal window it is transferring 0xff and 0x02 with delay in between to see the color diff on processing window there is no error in both code but then also it is not changing window color why??
I am suing processing 1.5 with XP 32bit and i want to do serial comm of uC using PIC16F877 with processing and tested that pic uC code in serial terminal window it is transferring 0xff and 0x02 with delay in between to see the color diff on processing window there is no error in both code but then also it is not changing window color why??
- #include <htc.h>
- __CONFIG(LVP_OFF & BOREN_OFF & PWRTE_ON & WDTE_OFF & FOSC_HS);
- #define _XTAL_FREQ 20000000
- void HSerinit(void), HseroutString(unsigned char* str), Hserout(unsigned char ch);
- void main(void) // program entry
- {
- TRISB=0x00;
- // <- LOOK HERE.
- ADCON1 = 0x6; // Analogue off
- HSerinit();
- __delay_ms(150);
- unsigned char ch=0;
- while(1)
- {
- ch=0xff ;
- Hserout(ch);
- __delay_ms(500);
- ch=0x02 ;
- Hserout(ch);
- __delay_ms(500);
- }
- }
- void HSerinit()
- {
- TRISC = 0x80; // TX was an input!
- SPBRG = 129; // 20Mhz xtal 9600 BAUD
- TXSTA = 0x24; // TXEN and BRGH
- RCSTA = 0x90; // SPEN and CREN
- }
- void Hserout(unsigned char ch)
- {
- while(!TXIF);
- TXREG = ch;
- }
- import processing.serial.*;
- Serial port; float brightness = 00;
- void setup()
- {
- size(1200, 600); //Set size of the window
- port = new Serial(this, "COM11", 9600); //change "COM11" to the usb port, you are using
- port.bufferUntil('\n'); //wait for a value to appear in the Serial monitor
- }
- void draw()
- { background(0, 0, brightness);
- }
- void serialEvent (Serial port)
- {
- brightness = float(port.readStringUntil('\n'));
- }
1