CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

pic33f rs232 and dac problem

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
skara1214



Joined: 14 Sep 2011
Posts: 1

View user's profile Send private message

pic33f rs232 and dac problem
PostPosted: Wed Sep 14, 2011 9:20 am     Reply with quote

hi I have a pic33fj128gp802.I have problems with that first of all rs232.
I wrote this code
Code:

#include "33FJ128GP802.h"
#device ADC=12
#Fuses  NOWDT,NOPUT,HS,PR_PLL
#use delay(clock=80M,oscillator=10M)
#use rs232 (baud=9600,xmit=PIN_B6, rcv=PIN_B7, parity=N, stop=1,STREAM=il)

void main()
{

while(1)
 {
  fprintf(il,"h\n\r");
  delay_ms(500);
 }

}

It's working but if I use more than 3 letter it's not working. What's the problem?

Second, I cannot use dac:
Code:

#include "33FJ128GP802.h"
#device ADC=12

#word DAC1CON =0x03F0
#word DAC1STAT =0x03F2
#word DAC1DFLT =0x03F4
#word DAC1RDAT =0x03F6

#Fuses  NOWDT,NOPUT,HS,PR_PLL
#use delay(clock=80M,oscillator=10M)

unsigned int16 i=10000,z=0;

void main()
{
disable_interrupts(INTR_GLOBAL);
DAC1CON=0b1001000000000101;
DAC1STAT=0b0000000010000000;
DAC1DFLT=0x0000;

while(1)
 {
  DAC1RDAT=i;
  delay_ms(2000);
  DAC1RDAT=z;
  delay_ms(2000);
 }

}

How can I fix it?

And the last one I cannot use 160 Mhz. Its working at 80 Mhz correctly but not at 160 Mhz. What should I change at fuses or somewhere else?
temtronic



Joined: 01 Jul 2010
Posts: 9245
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Sep 14, 2011 1:32 pm     Reply with quote

I don't use that PIC but...
... as far as the communications problem, it could very easily be whatever you're sending the data to is not running correctly. It doesn't matter to the PIC whether is send 1, 3 or 23 characters to 'somewhere', the code is the same.

However for receiving it is important to add 'errors' to the USE RS232(....) options to avoid buffer overflow...

.. as far as the DAC, can't help there, just be sure the addresses are correct for your PIC ! Not all PICs have the same addreses for peripherals!

... as for the speed issue. Are you sure that PIC will run at 160MHz ??? If so, look at the header for the correct fuse selection.

I'd be running it at a somewhat 'normal' speed(say 20MHz) for testing purposes, especially since my analog scope isn't very fast !!
Also at those higher speeds board layout is CRITICAL !!! You MUST follow the datasheet's comments for layout, part selection,etc.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group