Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

dsPIC33FJ256GP710A Analog over serial to Arduino

Status
Not open for further replies.

drkidd22

Member
Hello,

I'm having difficulty getting the ADC values from the dsPIC33FJ256GP710A transmitted over to an Arduino.
I have the dsPic configured correctly for 12-bits and the USART is working properly at 9600 baud. So they are talking ok with each other.

The issue I'm having is splitting up the ADC value and then transmitting it over the USART.
for example
Code:
U1TXREG = GetAdc(11);
gets the ADC Value and transmits it over, but the receiver all it gets is garbage.
The value of GetAdc(11) when inspected with the watch window is 0x07FF or 2047, which is correct for a 1.5V input to AN11 with a 3V ref.

I know I have to split this into smaller bytes before transmitting it over or use some other type of function. Any advice will be appreciated.
 
OK so I got this to split the ADC integer into 2-bytes and successfully transmit it over the USART, now how can I join them on the receiving end?

Code:
         adcVal = GetAdc(11);
         inBytes[0] = (adcVal >> 8) & 0xFF;
         inBytes[1] = adcVal & 0xFF;
         U1TXREG = inBytes[0];
         delay(500);
         U1TXREG = inBytes[1];
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top