Microchip C30

dsPIC serial ports

In general the dsPIC is well blessed with peripherals. The dsPIC30F6015 I am using at the moment has two serial ports in addition to a couple of SPI ports and an I2C port. These UARTs seem pretty easy to use as well. Still, like other peripherals on the dsPIC, they still found a way to catch me out. My own fault for not reading the data sheet properly. The trick here is to realise that there are FIFO buffers associated with the ports.

Integer promotion in C30

I was having a browse through the book 'Programming 16-bit Microcontrollers in C. Learning to Fly the PIC24' by Lucio Di Jasio. Leaving aside for now the tendency for authors to use overlong titles, there seems to me some interesting stuff in there. Early on there is a bit about what happens when you assign an int to a long as in this code fragment: int intvar; long longvar; longvar = intvar; In the book it says that the int is copied into the lower 16 bits of the long and the upper 16 bits are filled with zeros. Well, Iwould hope not.